XCSF
1.4.7
XCSF learning classifier system
|
Multi-layer perceptron neural network prediction functions. More...
#include "pred_neural.h"
#include "neural_activations.h"
#include "neural_layer_avgpool.h"
#include "neural_layer_connected.h"
#include "neural_layer_convolutional.h"
#include "neural_layer_dropout.h"
#include "neural_layer_lstm.h"
#include "neural_layer_maxpool.h"
#include "neural_layer_noise.h"
#include "neural_layer_recurrent.h"
#include "neural_layer_softmax.h"
#include "neural_layer_upsample.h"
#include "utils.h"
Go to the source code of this file.
Functions | |
void | pred_neural_init (const struct XCSF *xcsf, struct Cl *c) |
Creates and initialises a neural network prediction. More... | |
void | pred_neural_free (const struct XCSF *xcsf, const struct Cl *c) |
Frees the memory used by a neural network prediction. More... | |
void | pred_neural_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src) |
Copies a neural network prediction from one classifier to another. More... | |
void | pred_neural_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y) |
Backward propagates and updates a neural network prediction. More... | |
void | pred_neural_compute (const struct XCSF *xcsf, const struct Cl *c, const double *x) |
Forward propagates a neural network prediction with a provided input. More... | |
void | pred_neural_print (const struct XCSF *xcsf, const struct Cl *c) |
Prints a neural network prediction. More... | |
bool | pred_neural_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2) |
Dummy function since neural predictions do not perform crossover. More... | |
bool | pred_neural_mutate (const struct XCSF *xcsf, const struct Cl *c) |
Mutates a neural network prediction. More... | |
double | pred_neural_size (const struct XCSF *xcsf, const struct Cl *c) |
Returns the size of a neural network prediction. More... | |
size_t | pred_neural_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp) |
Writes a neural network prediction to a file. More... | |
size_t | pred_neural_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp) |
Reads a neural network prediction from a file. More... | |
double | pred_neural_eta (const struct XCSF *xcsf, const struct Cl *c, const int layer) |
Returns the gradient descent rate of a neural prediction layer. More... | |
int | pred_neural_neurons (const struct XCSF *xcsf, const struct Cl *c, const int layer) |
Returns the number of neurons in a neural prediction layer. More... | |
int | pred_neural_connections (const struct XCSF *xcsf, const struct Cl *c, const int layer) |
Returns the number of active connections in a neural prediction layer. More... | |
int | pred_neural_layers (const struct XCSF *xcsf, const struct Cl *c) |
Returns the number of layers within a neural network prediction. More... | |
void | pred_neural_expand (const struct XCSF *xcsf, const struct Cl *c) |
Creates and inserts a hidden layer before the prediction output layer. More... | |
void | pred_neural_ae_to_classifier (const struct XCSF *xcsf, const struct Cl *c, const int n_del) |
Removes prediction (decoder) layers and inserts softmax output layer. More... | |
char * | pred_neural_json_export (const struct XCSF *xcsf, const struct Cl *c) |
Returns a json formatted string representation of a neural prediction. More... | |
void | pred_neural_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json) |
Creates a neural prediction from a cJSON object. More... | |
void | pred_neural_param_defaults (struct XCSF *xcsf) |
Initialises default neural prediction parameters. More... | |
char * | pred_neural_param_json_import (struct XCSF *xcsf, cJSON *json) |
Sets the neural network parameters from a cJSON object. More... | |
Multi-layer perceptron neural network prediction functions.
Definition in file pred_neural.c.
void pred_neural_ae_to_classifier | ( | const struct XCSF * | xcsf, |
const struct Cl * | c, | ||
const int | n_del | ||
) |
Removes prediction (decoder) layers and inserts softmax output layer.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier to convert from autoencoding to classification. |
[in] | n_del | Number of (decoder) layers to remove from the network. |
Definition at line 349 of file pred_neural.c.
References CONNECTED, ArgsLayer::decay, ArgsLayer::eta, ArgsLayer::eta_min, ArgsLayer::evolve_connect, ArgsLayer::evolve_eta, ArgsLayer::evolve_weights, Layer::i, layer_args_init(), layer_init(), LINEAR, ArgsLayer::momentum, Net::n_layers, Net::n_outputs, PredNeural::net, neural_pop(), neural_push(), Cl::pred, ArgsLayer::sgd_weights, and SOFTMAX.
Referenced by xcsf_ae_to_classifier().
Forward propagates a neural network prediction with a provided input.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier calculating the prediction. |
[in] | x | The input state. |
Definition at line 106 of file pred_neural.c.
References PredNeural::net, neural_output(), neural_propagate(), Cl::pred, and Cl::prediction.
Returns the number of active connections in a neural prediction layer.
[in] | xcsf | The XCSF data structure. |
[in] | c | Classifier maintaining a neural network prediction. |
[in] | layer | Position of a layer in the network. |
Definition at line 268 of file pred_neural.c.
References Llist::layer, Layer::n_active, PredNeural::net, Cl::pred, Llist::prev, and Net::tail.
Referenced by clset_mean_pred_connections().
Copies a neural network prediction from one classifier to another.
[in] | xcsf | The XCSF data structure. |
[in] | dest | The destination classifier. |
[in] | src | The source classifier. |
Definition at line 73 of file pred_neural.c.
References PredNeural::net, neural_copy(), and Cl::pred.
Dummy function since neural predictions do not perform crossover.
[in] | xcsf | The XCSF data structure. |
[in] | c1 | The first classifier whose prediction is being crossed. |
[in] | c2 | The second classifier whose prediction is being crossed. |
Definition at line 137 of file pred_neural.c.
Returns the gradient descent rate of a neural prediction layer.
[in] | xcsf | The XCSF data structure. |
[in] | c | Classifier maintaining a neural network prediction. |
[in] | layer | Position of a layer in the network. |
Definition at line 216 of file pred_neural.c.
References Layer::eta, Llist::layer, PredNeural::net, Cl::pred, Llist::prev, and Net::tail.
Referenced by clset_mean_pred_eta().
Creates and inserts a hidden layer before the prediction output layer.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose neural prediction is to be expanded. |
Definition at line 306 of file pred_neural.c.
References CONNECTED, ArgsLayer::decay, ArgsLayer::eta, ArgsLayer::eta_min, ArgsLayer::evolve_connect, ArgsLayer::evolve_eta, ArgsLayer::evolve_functions, ArgsLayer::evolve_weights, ArgsLayer::function, Layer::h, Net::head, Llist::layer, layer_args_init(), layer_init(), Layer::max_outputs, ArgsLayer::momentum, Layer::n_inputs, ArgsLayer::n_inputs, Net::n_layers, Layer::n_outputs, PredNeural::net, neural_insert(), neural_resize(), Llist::next, Cl::pred, and ArgsLayer::sgd_weights.
Referenced by xcsf_pred_expand().
Frees the memory used by a neural network prediction.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose prediction is to be freed. |
Definition at line 58 of file pred_neural.c.
References PredNeural::net, neural_free(), and Cl::pred.
Creates and initialises a neural network prediction.
Uses fully-connected layers.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose prediction is to be initialised. |
Definition at line 45 of file pred_neural.c.
References neural_create(), and Cl::pred.
Returns a json formatted string representation of a neural prediction.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose prediction is to be returned. |
Definition at line 392 of file pred_neural.c.
References PredNeural::net, neural_json_export(), and Cl::pred.
Referenced by pred_neural_print().
Creates a neural prediction from a cJSON object.
[in] | xcsf | The XCSF data structure. |
[in,out] | c | The classifier to initialise. |
[in] | json | cJSON object. |
Definition at line 414 of file pred_neural.c.
References PredNeural::net, neural_json_import(), and Cl::pred.
Returns the number of layers within a neural network prediction.
[in] | xcsf | The XCSF data structure. |
[in] | c | Classifier maintaining a neural network prediction. |
Definition at line 292 of file pred_neural.c.
References Net::n_layers, PredNeural::net, and Cl::pred.
Referenced by clset_mean_pred_layers().
Reads a neural network prediction from a file.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose prediction is to be read. |
[in] | fp | Pointer to the file to be read. |
Definition at line 199 of file pred_neural.c.
References neural_load(), and Cl::pred.
Mutates a neural network prediction.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose prediction is being mutated. |
Definition at line 153 of file pred_neural.c.
References PredNeural::net, neural_mutate(), and Cl::pred.
Returns the number of neurons in a neural prediction layer.
[in] | xcsf | The XCSF data structure. |
[in] | c | Classifier maintaining a neural network prediction. |
[in] | layer | Position of a layer in the network. |
Definition at line 240 of file pred_neural.c.
References CONVOLUTIONAL, Llist::layer, Layer::n_filters, Layer::n_outputs, PredNeural::net, Cl::pred, Llist::prev, Net::tail, and Layer::type.
Referenced by clset_mean_pred_neurons().
void pred_neural_param_defaults | ( | struct XCSF * | xcsf | ) |
Initialises default neural prediction parameters.
[in] | xcsf | The XCSF data structure. |
Definition at line 431 of file pred_neural.c.
References CONNECTED, ArgsLayer::eta, ArgsLayer::evolve_connect, ArgsLayer::evolve_eta, ArgsLayer::evolve_neurons, ArgsLayer::evolve_weights, ArgsLayer::function, layer_args_copy(), layer_args_init(), LOGISTIC, ArgsLayer::max_neuron_grow, ArgsLayer::momentum, ArgsLayer::n_init, ArgsLayer::n_inputs, ArgsLayer::n_max, ArgsLayer::next, ArgsLayer::sgd_weights, and ArgsLayer::type.
Referenced by pred_param_defaults().
char* pred_neural_param_json_import | ( | struct XCSF * | xcsf, |
cJSON * | json | ||
) |
Sets the neural network parameters from a cJSON object.
[in,out] | xcsf | The XCSF data structure. |
[in] | json | cJSON object. |
Definition at line 465 of file pred_neural.c.
References layer_args_free(), layer_args_init(), layer_args_json_import(), layer_args_validate(), ArgsLayer::n_inputs, and ArgsLayer::next.
Referenced by pred_param_json_import().
Prints a neural network prediction.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose prediction is to be printed. |
Definition at line 122 of file pred_neural.c.
References pred_neural_json_export().
Writes a neural network prediction to a file.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose prediction is to be written. |
[in] | fp | Pointer to the file to be written. |
Definition at line 183 of file pred_neural.c.
References PredNeural::net, neural_save(), and Cl::pred.
Returns the size of a neural network prediction.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose prediction size to return. |
Definition at line 168 of file pred_neural.c.
References PredNeural::net, neural_size(), and Cl::pred.
void pred_neural_update | ( | const struct XCSF * | xcsf, |
const struct Cl * | c, | ||
const double * | x, | ||
const double * | y | ||
) |
Backward propagates and updates a neural network prediction.
[in] | xcsf | The XCSF data structure. |
[in] | c | Classifier whose prediction is to be updated. |
[in] | x | Input state. |
[in] | y | Truth/payoff value. |
Definition at line 91 of file pred_neural.c.
References PredNeural::net, neural_learn(), and Cl::pred.