XCSF  1.4.7
XCSF learning classifier system
neural_layer_args.c File Reference

Functions operating on neural network arguments/constants. More...

Include dependency graph for neural_layer_args.c:

Go to the source code of this file.

Functions

void layer_args_init (struct ArgsLayer *args)
 Sets layer parameters to default values. More...
 
struct ArgsLayerlayer_args_copy (const struct ArgsLayer *src)
 Creates and returns a copy of specified layer parameters. More...
 
static void layer_args_json_export_inputs (cJSON *json, const struct ArgsLayer *args)
 Adds layer input parameters to a json object. More...
 
static bool layer_args_json_import_inputs (struct ArgsLayer *args, const cJSON *json)
 Sets the layer input parameters from a cJSON object. More...
 
static void layer_args_json_export_sgd (cJSON *json, const struct ArgsLayer *args)
 Adds layer gradient descent parameters to a json object. More...
 
static bool layer_args_json_import_sgd (struct ArgsLayer *args, const cJSON *json)
 Sets the layer SGD parameters from a cJSON object. More...
 
static void layer_args_json_export_evo (cJSON *json, const struct ArgsLayer *args)
 Adds layer evolutionary parameters to a json object. More...
 
static bool layer_args_json_import_evo (struct ArgsLayer *args, const cJSON *json)
 Sets the layer evolutionary parameters from a cJSON object. More...
 
static void layer_args_json_export_activation (cJSON *json, const struct ArgsLayer *args)
 Adds layer activation function to a json object. More...
 
static bool layer_args_json_import_activation (struct ArgsLayer *args, const cJSON *json)
 Sets the layer activation from a cJSON object. More...
 
static bool layer_args_json_export_scale (cJSON *json, const struct ArgsLayer *args)
 Adds layer scaling parameters to a json object. More...
 
static bool layer_args_json_import_scale (struct ArgsLayer *args, const cJSON *json)
 Sets the layer scaling parameters from a cJSON object. More...
 
char * layer_args_json_export (struct ArgsLayer *args)
 Returns a json formatted string of the neural layer parameters. More...
 
char * layer_args_json_import (struct ArgsLayer *args, cJSON *json)
 Sets the layer parameters from a cJSON object. More...
 
void layer_args_free (struct ArgsLayer **largs)
 Frees memory used by a list of layer parameters and points to NULL. More...
 
static void layer_args_validate_inputs (struct ArgsLayer *arg)
 Checks input layer arguments are valid. More...
 
void layer_args_validate (struct ArgsLayer *args)
 Checks network layer arguments are valid. More...
 
struct ArgsLayerlayer_args_tail (struct ArgsLayer *head)
 Returns the current output layer arguments. More...
 
uint32_t layer_args_opt (const struct ArgsLayer *args)
 Returns a bitstring representing the permissions granted by a layer. More...
 
static int layer_args_length (const struct ArgsLayer *args)
 Returns the length of the neural network layer parameter list. More...
 
size_t layer_args_save (const struct ArgsLayer *args, FILE *fp)
 Saves neural network layer parameters. More...
 
size_t layer_args_load (struct ArgsLayer **largs, FILE *fp)
 Loads neural network layer parameters. More...
 

Detailed Description

Functions operating on neural network arguments/constants.

Author
Richard Preen rpree.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om
Date
2020–2023.

Definition in file neural_layer_args.c.

Function Documentation

◆ layer_args_copy()

◆ layer_args_free()

void layer_args_free ( struct ArgsLayer **  largs)

Frees memory used by a list of layer parameters and points to NULL.

Parameters
[in]largsPointer to the list of layer parameters to free.

Definition at line 451 of file neural_layer_args.c.

References ArgsLayer::next.

Referenced by act_neural_param_json_import(), action_param_free(), cond_neural_param_json_import(), cond_param_free(), layer_args_load(), pred_neural_param_json_import(), and pred_param_free().

Here is the caller graph for this function:

◆ layer_args_init()

◆ layer_args_json_export()

char* layer_args_json_export ( struct ArgsLayer args)

Returns a json formatted string of the neural layer parameters.

Parameters
[in]argsThe layer parameters to print.
Returns
String encoded in json format.

Definition at line 377 of file neural_layer_args.c.

References layer_args_json_export_activation(), layer_args_json_export_evo(), layer_args_json_export_inputs(), layer_args_json_export_scale(), layer_args_json_export_sgd(), layer_type_as_string(), neural_create(), neural_free(), neural_init(), and ArgsLayer::next.

Referenced by action_param_json_export(), cond_param_json_export(), and pred_param_json_export().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layer_args_json_export_activation()

static void layer_args_json_export_activation ( cJSON *  json,
const struct ArgsLayer args 
)
static

Adds layer activation function to a json object.

Parameters
[in,out]jsoncJSON object.
[in]argsThe layer parameters.

Definition at line 283 of file neural_layer_args.c.

References AVGPOOL, DROPOUT, ArgsLayer::function, LSTM, MAXPOOL, neural_activation_string(), NOISE, ArgsLayer::recurrent_function, SOFTMAX, ArgsLayer::type, and UPSAMPLE.

Referenced by layer_args_json_export().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layer_args_json_export_evo()

static void layer_args_json_export_evo ( cJSON *  json,
const struct ArgsLayer args 
)
static

Adds layer evolutionary parameters to a json object.

Parameters
[in,out]jsoncJSON object.
[in]argsThe layer parameters to print.

Definition at line 232 of file neural_layer_args.c.

References ArgsLayer::evolve_connect, ArgsLayer::evolve_functions, ArgsLayer::evolve_neurons, ArgsLayer::evolve_weights, ArgsLayer::max_neuron_grow, and ArgsLayer::n_max.

Referenced by layer_args_json_export().

Here is the caller graph for this function:

◆ layer_args_json_export_inputs()

static void layer_args_json_export_inputs ( cJSON *  json,
const struct ArgsLayer args 
)
static

Adds layer input parameters to a json object.

Parameters
[in,out]jsoncJSON object.
[in]argsThe layer parameters.

Definition at line 115 of file neural_layer_args.c.

References ArgsLayer::channels, ArgsLayer::height, layer_receives_images(), ArgsLayer::n_inputs, ArgsLayer::pad, ArgsLayer::size, ArgsLayer::stride, ArgsLayer::type, and ArgsLayer::width.

Referenced by layer_args_json_export().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layer_args_json_export_scale()

static bool layer_args_json_export_scale ( cJSON *  json,
const struct ArgsLayer args 
)
static

Adds layer scaling parameters to a json object.

Parameters
[in,out]jsoncJSON object.
[in]argsThe layer parameters to print.
Returns
Whether to move to the next layer.

Definition at line 333 of file neural_layer_args.c.

References DROPOUT, MAXPOOL, NOISE, ArgsLayer::probability, ArgsLayer::scale, SOFTMAX, and ArgsLayer::type.

Referenced by layer_args_json_export().

Here is the caller graph for this function:

◆ layer_args_json_export_sgd()

static void layer_args_json_export_sgd ( cJSON *  json,
const struct ArgsLayer args 
)
static

Adds layer gradient descent parameters to a json object.

Parameters
[in,out]jsoncJSON object.
[in]argsThe layer parameters to print.

Definition at line 181 of file neural_layer_args.c.

References ArgsLayer::decay, ArgsLayer::eta, ArgsLayer::eta_min, ArgsLayer::evolve_eta, ArgsLayer::momentum, and ArgsLayer::sgd_weights.

Referenced by layer_args_json_export().

Here is the caller graph for this function:

◆ layer_args_json_import()

char* layer_args_json_import ( struct ArgsLayer args,
cJSON *  json 
)

Sets the layer parameters from a cJSON object.

Parameters
[in,out]argsLayer parameters data structure.
[in]jsoncJSON object.
Returns
NULL if successful; or the name of parameter if not found.

Definition at line 415 of file neural_layer_args.c.

References layer_args_json_import_activation(), layer_args_json_import_evo(), layer_args_json_import_inputs(), layer_args_json_import_scale(), layer_args_json_import_sgd(), layer_type_as_int(), ArgsLayer::n_init, and ArgsLayer::type.

Referenced by act_neural_param_json_import(), cond_neural_param_json_import(), and pred_neural_param_json_import().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layer_args_json_import_activation()

static bool layer_args_json_import_activation ( struct ArgsLayer args,
const cJSON *  json 
)
static

Sets the layer activation from a cJSON object.

Parameters
[in,out]argsLayer parameters data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 312 of file neural_layer_args.c.

References ArgsLayer::function, neural_activation_as_int(), and ArgsLayer::recurrent_function.

Referenced by layer_args_json_import().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layer_args_json_import_evo()

static bool layer_args_json_import_evo ( struct ArgsLayer args,
const cJSON *  json 
)
static

Sets the layer evolutionary parameters from a cJSON object.

Parameters
[in,out]argsLayer parameters data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 251 of file neural_layer_args.c.

References ArgsLayer::evolve_connect, ArgsLayer::evolve_functions, ArgsLayer::evolve_neurons, ArgsLayer::evolve_weights, ArgsLayer::max_neuron_grow, and ArgsLayer::n_max.

Referenced by layer_args_json_import().

Here is the caller graph for this function:

◆ layer_args_json_import_inputs()

static bool layer_args_json_import_inputs ( struct ArgsLayer args,
const cJSON *  json 
)
static

Sets the layer input parameters from a cJSON object.

Parameters
[in,out]argsLayer parameters data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 148 of file neural_layer_args.c.

References ArgsLayer::channels, ArgsLayer::height, ArgsLayer::n_inputs, ArgsLayer::pad, ArgsLayer::size, ArgsLayer::stride, and ArgsLayer::width.

Referenced by layer_args_json_import().

Here is the caller graph for this function:

◆ layer_args_json_import_scale()

static bool layer_args_json_import_scale ( struct ArgsLayer args,
const cJSON *  json 
)
static

Sets the layer scaling parameters from a cJSON object.

Parameters
[in,out]argsLayer parameters data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 357 of file neural_layer_args.c.

References ArgsLayer::probability, and ArgsLayer::scale.

Referenced by layer_args_json_import().

Here is the caller graph for this function:

◆ layer_args_json_import_sgd()

static bool layer_args_json_import_sgd ( struct ArgsLayer args,
const cJSON *  json 
)
static

Sets the layer SGD parameters from a cJSON object.

Parameters
[in,out]argsLayer parameters data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 202 of file neural_layer_args.c.

References ArgsLayer::decay, ArgsLayer::eta, ArgsLayer::eta_min, ArgsLayer::evolve_eta, ArgsLayer::momentum, and ArgsLayer::sgd_weights.

Referenced by layer_args_json_import().

Here is the caller graph for this function:

◆ layer_args_length()

static int layer_args_length ( const struct ArgsLayer args)
static

Returns the length of the neural network layer parameter list.

Parameters
[in]argsLayer initialisation parameters.
Returns
The list length.

Definition at line 571 of file neural_layer_args.c.

References ArgsLayer::next.

Referenced by layer_args_save().

Here is the caller graph for this function:

◆ layer_args_load()

size_t layer_args_load ( struct ArgsLayer **  largs,
FILE *  fp 
)

Loads neural network layer parameters.

Parameters
[in]largsPointer to the list of layer parameters to load.
[in]fpPointer to the output file.
Returns
The total number of elements read.

Definition at line 633 of file neural_layer_args.c.

References ArgsLayer::channels, ArgsLayer::decay, ArgsLayer::eta, ArgsLayer::eta_min, ArgsLayer::evolve_connect, ArgsLayer::evolve_eta, ArgsLayer::evolve_functions, ArgsLayer::evolve_neurons, ArgsLayer::evolve_weights, ArgsLayer::function, ArgsLayer::height, layer_args_free(), layer_args_init(), ArgsLayer::max_neuron_grow, ArgsLayer::momentum, ArgsLayer::n_init, ArgsLayer::n_inputs, ArgsLayer::n_max, ArgsLayer::next, ArgsLayer::pad, ArgsLayer::probability, ArgsLayer::recurrent_function, ArgsLayer::scale, ArgsLayer::sgd_weights, ArgsLayer::size, ArgsLayer::stride, ArgsLayer::type, and ArgsLayer::width.

Referenced by action_param_load(), cond_param_load(), and pred_param_load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layer_args_opt()

uint32_t layer_args_opt ( const struct ArgsLayer args)

Returns a bitstring representing the permissions granted by a layer.

Parameters
[in]argsLayer initialisation parameters.
Returns
Bitstring representing the layer options.

Definition at line 541 of file neural_layer_args.c.

References ArgsLayer::evolve_connect, ArgsLayer::evolve_eta, ArgsLayer::evolve_functions, ArgsLayer::evolve_neurons, ArgsLayer::evolve_weights, LAYER_EVOLVE_CONNECT, LAYER_EVOLVE_ETA, LAYER_EVOLVE_FUNCTIONS, LAYER_EVOLVE_NEURONS, LAYER_EVOLVE_WEIGHTS, LAYER_SGD_WEIGHTS, and ArgsLayer::sgd_weights.

Referenced by neural_layer_connected_init(), neural_layer_convolutional_init(), neural_layer_lstm_init(), and neural_layer_recurrent_init().

Here is the caller graph for this function:

◆ layer_args_save()

size_t layer_args_save ( const struct ArgsLayer args,
FILE *  fp 
)

Saves neural network layer parameters.

Parameters
[in]argsLayer initialisation parameters.
[in]fpPointer to the output file.
Returns
The total number of elements written.

Definition at line 589 of file neural_layer_args.c.

References ArgsLayer::channels, ArgsLayer::decay, ArgsLayer::eta, ArgsLayer::eta_min, ArgsLayer::evolve_connect, ArgsLayer::evolve_eta, ArgsLayer::evolve_functions, ArgsLayer::evolve_neurons, ArgsLayer::evolve_weights, ArgsLayer::function, ArgsLayer::height, layer_args_length(), ArgsLayer::max_neuron_grow, ArgsLayer::momentum, ArgsLayer::n_init, ArgsLayer::n_inputs, ArgsLayer::n_max, ArgsLayer::next, ArgsLayer::pad, ArgsLayer::probability, ArgsLayer::recurrent_function, ArgsLayer::scale, ArgsLayer::sgd_weights, ArgsLayer::size, ArgsLayer::stride, ArgsLayer::type, and ArgsLayer::width.

Referenced by action_param_save(), cond_param_save(), and pred_param_save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layer_args_tail()

struct ArgsLayer* layer_args_tail ( struct ArgsLayer head)

Returns the current output layer arguments.

Parameters
[in]headHead of the list of layer parameters.
Returns
Layer parameters pertaining to the current output layer.

Definition at line 526 of file neural_layer_args.c.

References ArgsLayer::next.

◆ layer_args_validate()

void layer_args_validate ( struct ArgsLayer args)

Checks network layer arguments are valid.

Parameters
[in]argsList of layer parameters to check.

Definition at line 500 of file neural_layer_args.c.

References ArgsLayer::evolve_neurons, layer_args_validate_inputs(), ArgsLayer::max_neuron_grow, ArgsLayer::n_init, ArgsLayer::n_max, and ArgsLayer::next.

Referenced by act_neural_param_json_import(), cond_neural_param_json_import(), and pred_neural_param_json_import().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layer_args_validate_inputs()

static void layer_args_validate_inputs ( struct ArgsLayer arg)
static

Checks input layer arguments are valid.

Parameters
[in]argInput layer parameters.

Definition at line 465 of file neural_layer_args.c.

References ArgsLayer::channels, DROPOUT, ArgsLayer::height, layer_receives_images(), ArgsLayer::n_inputs, NOISE, ArgsLayer::type, and ArgsLayer::width.

Referenced by layer_args_validate().

Here is the call graph for this function:
Here is the caller graph for this function: