185 printf(
"%s\n", json_str);
249 const struct Net *net = &cond->
net;
252 while (iter != NULL) {
277 const struct Net *net = &cond->
net;
280 while (iter != NULL) {
301 const struct Net *net = &cond->
net;
316 cJSON *json = cJSON_CreateObject();
317 cJSON_AddStringToObject(json,
"type",
"neural");
319 cJSON *network = cJSON_Parse(network_str);
321 cJSON_AddItemToObject(json,
"network", network);
322 char *
string = cJSON_Print(json);
337 const cJSON *item = cJSON_GetObjectItem(json,
"network");
339 printf(
"Import error: missing network\n");
356 for (cJSON *iter = json; iter != NULL; iter = iter->next) {
364 if (
xcsf->cond->largs == NULL) {
365 xcsf->cond->largs = larg;
368 while (layer_iter->
next != NULL) {
369 layer_iter = layer_iter->
next;
371 layer_iter->
next = larg;
397 xcsf->cond->largs = args;
bool cond_neural_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy general function.
bool cond_neural_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy crossover function.
void cond_neural_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a neural condition from a cJSON object.
int cond_neural_neurons(const struct XCSF *xcsf, const struct Cl *c, int layer)
Returns the number of neurons in a neural condition layer.
void cond_neural_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises a neural network condition.
int cond_neural_layers(const struct XCSF *xcsf, const struct Cl *c)
Returns the number of layers within a neural network condition.
void cond_neural_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a neural network condition.
size_t cond_neural_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a neural network condition to a file.
char * cond_neural_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a neural condition.
bool cond_neural_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a neural network that matches the current input.
double cond_neural_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a neural network condition.
size_t cond_neural_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a neural network condition from a file.
char * cond_neural_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the neural network parameters from a cJSON object.
void cond_neural_param_defaults(struct XCSF *xcsf)
Initialises default neural condition parameters.
void cond_neural_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Dummy update function.
int cond_neural_connections(const struct XCSF *xcsf, const struct Cl *c, int layer)
Returns the number of active connections in a neural condition layer.
bool cond_neural_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a neural network condition with the self-adaptive rates.
void cond_neural_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a neural network that matches the current input.
void cond_neural_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a neural network condition.
void cond_neural_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a neural network condition from one classifier to another.
Multi-layer perceptron neural network condition functions.
bool neural_mutate(const struct Net *net)
Mutates a neural network.
double neural_size(const struct Net *net)
Returns the total number of non-zero weights in a neural network.
void neural_create(struct Net *net, struct ArgsLayer *arg)
Initialises and creates a new neural network from a parameter list.
double neural_output(const struct Net *net, const int IDX)
Returns the output of a specified neuron in the output layer of a neural network.
size_t neural_load(struct Net *net, FILE *fp)
Reads a neural network from a file.
void neural_json_import(struct Net *net, const struct ArgsLayer *arg, const cJSON *json)
Creates a neural network from a cJSON object.
void neural_free(struct Net *net)
Frees a neural network.
void neural_rand(const struct Net *net)
Randomises the layers within a neural network.
void neural_copy(struct Net *dest, const struct Net *src)
Copies a neural network.
void neural_propagate(struct Net *net, const double *input, const bool train)
Forward propagates a neural network.
char * neural_json_export(const struct Net *net, const bool return_weights)
Returns a json formatted string representation of a neural network.
size_t neural_save(const struct Net *net, FILE *fp)
Writes a neural network to a file.
Neural network activation functions.
#define LOGISTIC
Logistic [0,1].
#define LINEAR
Linear [-inf,inf].
#define CONVOLUTIONAL
Layer type convolutional.
#define CONNECTED
Layer type connected.
void layer_args_init(struct ArgsLayer *args)
Sets layer parameters to default values.
char * layer_args_json_import(struct ArgsLayer *args, cJSON *json)
Sets the layer parameters from a cJSON object.
void layer_args_free(struct ArgsLayer **largs)
Frees memory used by a list of layer parameters and points to NULL.
void layer_args_validate(struct ArgsLayer *args)
Checks network layer arguments are valid.
struct ArgsLayer * layer_args_copy(const struct ArgsLayer *src)
Creates and returns a copy of specified layer parameters.
An implementation of a fully-connected layer of perceptrons.
An implementation of a 2D convolutional layer.
An implementation of a dropout layer.
An implementation of a long short-term memory layer.
An implementation of a 2D maxpooling layer.
An implementation of a Gaussian noise adding layer.
An implementation of a recurrent layer of perceptrons.
An implementation of a softmax layer.
Parameters for initialising a neural network layer.
_Bool evolve_weights
Ability to evolve weights.
int n_init
Initial number of units / neurons / filters.
_Bool evolve_neurons
Ability to evolve number of units.
int function
Activation function.
int max_neuron_grow
Maximum number neurons to add per mutation event.
int n_max
Maximum number of units / neurons.
int n_inputs
Number of inputs.
int type
Layer type: CONNECTED, DROPOUT, etc.
struct ArgsLayer * next
Next layer parameters.
_Bool evolve_connect
Ability to evolve weight connectivity.
Classifier data structure.
void * cond
Condition structure.
Multi-layer perceptron neural network condition data structure.
struct Net net
Neural network.
int n_outputs
Number of layer outputs.
int n_active
Number of active weights / connections.
int type
Layer type: CONNECTED, DROPOUT, etc.
Forward declaration of layer structure.
struct Llist * prev
Pointer to the previous layer (forward)
struct Layer * layer
Pointer to the layer data structure.
Neural network data structure.
int n_layers
Number of layers (hidden + output)
struct Llist * tail
Pointer to the tail layer (first layer)
Utility functions for random number handling, etc.