XCSF
1.4.7
XCSF learning classifier system
|
Interface for neural network layers. More...
Go to the source code of this file.
Data Structures | |
struct | Layer |
Neural network layer data structure. More... | |
struct | LayerVtbl |
Neural network layer interface data structure. More... | |
Macros | |
#define | CONNECTED (0) |
Layer type connected. More... | |
#define | DROPOUT (1) |
Layer type dropout. More... | |
#define | NOISE (2) |
Layer type noise. More... | |
#define | SOFTMAX (3) |
Layer type softmax. More... | |
#define | RECURRENT (4) |
Layer type recurrent. More... | |
#define | LSTM (5) |
Layer type LSTM. More... | |
#define | MAXPOOL (6) |
Layer type maxpooling. More... | |
#define | CONVOLUTIONAL (7) |
Layer type convolutional. More... | |
#define | AVGPOOL (8) |
Layer type average pooling. More... | |
#define | UPSAMPLE (9) |
Layer type upsample. More... | |
#define | STRING_CONNECTED ("connected\0") |
Connected. More... | |
#define | STRING_DROPOUT ("dropout\0") |
Dropout. More... | |
#define | STRING_NOISE ("noise\0") |
Noise. More... | |
#define | STRING_SOFTMAX ("softmax\0") |
Softmax. More... | |
#define | STRING_RECURRENT ("recurrent\0") |
Recurrent. More... | |
#define | STRING_LSTM ("lstm\0") |
LSTM. More... | |
#define | STRING_MAXPOOL ("maxpool\0") |
Maxpool. More... | |
#define | STRING_CONVOLUTIONAL ("convolutional\0") |
Convolutional. More... | |
#define | STRING_AVGPOOL ("avgpool\0") |
Avgpool. More... | |
#define | STRING_UPSAMPLE ("upsample\0") |
Upsample. More... | |
#define | LAYER_EVOLVE_WEIGHTS (1 << 0) |
Layer may evolve weights. More... | |
#define | LAYER_EVOLVE_NEURONS (1 << 1) |
Layer may evolve neurons. More... | |
#define | LAYER_EVOLVE_FUNCTIONS (1 << 2) |
Layer may evolve functions. More... | |
#define | LAYER_SGD_WEIGHTS (1 << 3) |
Layer may perform gradient descent. More... | |
#define | LAYER_EVOLVE_ETA (1 << 4) |
Layer may evolve rate of gradient descent. More... | |
#define | LAYER_EVOLVE_CONNECT (1 << 5) |
Layer may evolve connectivity. More... | |
#define | NEURON_MIN (-100) |
Minimum neuron state. More... | |
#define | NEURON_MAX (100) |
Maximum neuron state. More... | |
#define | WEIGHT_MIN (-10) |
Minimum value of a weight or bias. More... | |
#define | WEIGHT_MAX (10) |
Maximum value of a weight or bias. More... | |
#define | N_WEIGHTS_MAX (20000000) |
Maximum number of weights per layer. More... | |
#define | N_INPUTS_MAX (2000000) |
Maximum number of inputs per layer. More... | |
#define | N_OUTPUTS_MAX (2000000) |
Maximum number of outputs per layer. More... | |
#define | WEIGHT_SD_INIT (0.1) |
Std dev of Gaussian for weight initialisation. More... | |
#define | WEIGHT_SD (0.1) |
Std dev of Gaussian for weight resizing. More... | |
#define | WEIGHT_SD_RAND (1.0) |
Std dev of Gaussian for weight randomising. More... | |
Functions | |
static double * | layer_output (const struct Layer *l) |
Returns the outputs of a layer. More... | |
static void | layer_forward (const struct Layer *l, const struct Net *net, const double *input) |
Forward propagates an input through the layer. More... | |
static void | layer_backward (const struct Layer *l, const struct Net *net, const double *input, double *delta) |
Backward propagates the error through a layer. More... | |
static void | layer_update (const struct Layer *l) |
Updates the weights and biases of a layer. More... | |
static bool | layer_mutate (struct Layer *l) |
Performs layer mutation. More... | |
static void | layer_resize (struct Layer *l, const struct Layer *prev) |
Resizes a layer using the previous layer's inputs. More... | |
static struct Layer * | layer_copy (const struct Layer *src) |
Creates and returns a copy of a specified layer. More... | |
static void | layer_free (const struct Layer *l) |
Frees the memory used by the layer. More... | |
static void | layer_rand (struct Layer *l) |
Randomises a layer. More... | |
static void | layer_print (const struct Layer *l, const bool print_weights) |
Prints the layer. More... | |
static char * | layer_json_export (const struct Layer *l, const bool return_weights) |
Returns a json formatted string representation of a layer. More... | |
bool | layer_mutate_connectivity (struct Layer *l, const double mu_enable, const double mu_disable) |
Mutates a layer's connectivity by zeroing weights. More... | |
bool | layer_mutate_eta (struct Layer *l, const double mu) |
Mutates the gradient descent rate of a neural layer. More... | |
bool | layer_mutate_functions (struct Layer *l, const double mu) |
Mutates a layer's activation function by random selection. More... | |
bool | layer_mutate_weights (struct Layer *l, const double mu) |
Mutates a layer's weights and biases by adding random numbers from a Gaussian normal distribution with zero mean and standard deviation equal to the mutation rate. More... | |
int | layer_mutate_neurons (const struct Layer *l, const double mu) |
Returns the number of neurons to add or remove from a layer. More... | |
void | layer_add_neurons (struct Layer *l, const int n) |
Adds N neurons to a layer. Negative N removes neurons. More... | |
void | layer_calc_n_active (struct Layer *l) |
Recalculates the number of active connections within a layer. More... | |
void | layer_defaults (struct Layer *l) |
Initialises a layer to default values. More... | |
void | layer_init_eta (struct Layer *l) |
Initialises a layer's gradient descent rate. More... | |
void | layer_set_vptr (struct Layer *l) |
Sets a neural network layer's functions to the implementations. More... | |
void | layer_weight_clamp (const struct Layer *l) |
Clamps a layer's weights and biases in range [WEIGHT_MIN, WEIGHT_MAX]. More... | |
void | layer_weight_print (const struct Layer *l, const bool print_weights) |
Prints a layer's weights and biases. More... | |
char * | layer_weight_json (const struct Layer *l, const bool return_weights) |
Returns a json formatted string representation of a layer's weights. More... | |
void | layer_weight_rand (struct Layer *l) |
Randomises a layer's weights and biases. More... | |
void | layer_ensure_input_represention (struct Layer *l) |
Ensures that each neuron is connected to at least one input and each input is connected to at least one neuron. More... | |
const char * | layer_type_as_string (const int type) |
Returns a string representation of a layer type from an integer. More... | |
int | layer_type_as_int (const char *type) |
Returns the integer representation of a layer type given a name. More... | |
bool | layer_receives_images (const int type) |
Returns a whether a layer type expects images as input. More... | |
void | layer_guard_biases (const struct Layer *l) |
Check number of biases is within bounds. More... | |
void | layer_guard_outputs (const struct Layer *l) |
Check number of outputs is within bounds. More... | |
void | layer_guard_weights (const struct Layer *l) |
Check number of weights is within bounds. More... | |
static struct Layer * | layer_init (const struct ArgsLayer *args) |
Creates and initialises a new layer. More... | |
static size_t | layer_save (const struct Layer *l, FILE *fp) |
Writes the layer to a file. More... | |
static size_t | layer_load (struct Layer *l, FILE *fp) |
Reads the layer from a file. More... | |
Interface for neural network layers.
Definition in file neural_layer.h.
#define AVGPOOL (8) |
Layer type average pooling.
Definition at line 37 of file neural_layer.h.
#define CONNECTED (0) |
Layer type connected.
Definition at line 29 of file neural_layer.h.
#define CONVOLUTIONAL (7) |
Layer type convolutional.
Definition at line 36 of file neural_layer.h.
#define DROPOUT (1) |
Layer type dropout.
Definition at line 30 of file neural_layer.h.
#define LAYER_EVOLVE_CONNECT (1 << 5) |
Layer may evolve connectivity.
Definition at line 56 of file neural_layer.h.
#define LAYER_EVOLVE_ETA (1 << 4) |
Layer may evolve rate of gradient descent.
Definition at line 55 of file neural_layer.h.
#define LAYER_EVOLVE_FUNCTIONS (1 << 2) |
Layer may evolve functions.
Definition at line 53 of file neural_layer.h.
#define LAYER_EVOLVE_NEURONS (1 << 1) |
Layer may evolve neurons.
Definition at line 52 of file neural_layer.h.
#define LAYER_EVOLVE_WEIGHTS (1 << 0) |
Layer may evolve weights.
Definition at line 51 of file neural_layer.h.
#define LAYER_SGD_WEIGHTS (1 << 3) |
Layer may perform gradient descent.
Definition at line 54 of file neural_layer.h.
#define LSTM (5) |
Layer type LSTM.
Definition at line 34 of file neural_layer.h.
#define MAXPOOL (6) |
Layer type maxpooling.
Definition at line 35 of file neural_layer.h.
#define N_INPUTS_MAX (2000000) |
Maximum number of inputs per layer.
Definition at line 63 of file neural_layer.h.
#define N_OUTPUTS_MAX (2000000) |
Maximum number of outputs per layer.
Definition at line 64 of file neural_layer.h.
#define N_WEIGHTS_MAX (20000000) |
Maximum number of weights per layer.
Definition at line 62 of file neural_layer.h.
#define NEURON_MAX (100) |
Maximum neuron state.
Definition at line 59 of file neural_layer.h.
#define NEURON_MIN (-100) |
Minimum neuron state.
Definition at line 58 of file neural_layer.h.
#define NOISE (2) |
Layer type noise.
Definition at line 31 of file neural_layer.h.
#define RECURRENT (4) |
Layer type recurrent.
Definition at line 33 of file neural_layer.h.
#define SOFTMAX (3) |
Layer type softmax.
Definition at line 32 of file neural_layer.h.
#define STRING_AVGPOOL ("avgpool\0") |
Avgpool.
Definition at line 48 of file neural_layer.h.
#define STRING_CONNECTED ("connected\0") |
Connected.
Definition at line 40 of file neural_layer.h.
#define STRING_CONVOLUTIONAL ("convolutional\0") |
Convolutional.
Definition at line 47 of file neural_layer.h.
#define STRING_DROPOUT ("dropout\0") |
Dropout.
Definition at line 41 of file neural_layer.h.
#define STRING_LSTM ("lstm\0") |
LSTM.
Definition at line 45 of file neural_layer.h.
#define STRING_MAXPOOL ("maxpool\0") |
Maxpool.
Definition at line 46 of file neural_layer.h.
#define STRING_NOISE ("noise\0") |
Noise.
Definition at line 42 of file neural_layer.h.
#define STRING_RECURRENT ("recurrent\0") |
Recurrent.
Definition at line 44 of file neural_layer.h.
#define STRING_SOFTMAX ("softmax\0") |
Softmax.
Definition at line 43 of file neural_layer.h.
#define STRING_UPSAMPLE ("upsample\0") |
Upsample.
Definition at line 49 of file neural_layer.h.
#define UPSAMPLE (9) |
Layer type upsample.
Definition at line 38 of file neural_layer.h.
#define WEIGHT_MAX (10) |
Maximum value of a weight or bias.
Definition at line 61 of file neural_layer.h.
#define WEIGHT_MIN (-10) |
Minimum value of a weight or bias.
Definition at line 60 of file neural_layer.h.
#define WEIGHT_SD (0.1) |
Std dev of Gaussian for weight resizing.
Definition at line 67 of file neural_layer.h.
#define WEIGHT_SD_INIT (0.1) |
Std dev of Gaussian for weight initialisation.
Definition at line 66 of file neural_layer.h.
#define WEIGHT_SD_RAND (1.0) |
Std dev of Gaussian for weight randomising.
Definition at line 68 of file neural_layer.h.
void layer_add_neurons | ( | struct Layer * | l, |
const int | N | ||
) |
Adds N neurons to a layer. Negative N removes neurons.
[in] | l | The neural network layer to mutate. |
[in] | N | The number of neurons to add. |
Definition at line 130 of file neural_layer.c.
References Layer::bias_updates, Layer::biases, Layer::delta, layer_calc_n_active(), LAYER_EVOLVE_CONNECT, layer_guard_outputs(), layer_guard_weights(), Layer::n_biases, Layer::n_inputs, Layer::n_outputs, Layer::n_weights, Layer::options, Layer::output, rand_normal(), rand_uniform(), Layer::state, Layer::weight_active, WEIGHT_SD, Layer::weight_updates, and Layer::weights.
Referenced by mutate_neurons(), and neural_layer_connected_mutate().
|
static |
Backward propagates the error through a layer.
[in] | l | The layer to be backward propagated. |
[in] | net | Network containing the layer. |
[in] | input | The input to the layer. |
[out] | delta | The previous layer's delta. |
Definition at line 194 of file neural_layer.h.
References Layer::delta, LayerVtbl::layer_impl_backward, and Layer::layer_vptr.
Referenced by neural_layer_lstm_backward(), neural_layer_recurrent_backward(), and neural_learn().
void layer_calc_n_active | ( | struct Layer * | l | ) |
Recalculates the number of active connections within a layer.
[in] | l | The layer to recalculate the number of active connections. |
Definition at line 384 of file neural_layer.c.
References Layer::n_active, Layer::n_weights, and Layer::weight_active.
Referenced by layer_add_neurons(), neural_layer_connected_resize(), neural_layer_convolutional_add_filters(), and neural_layer_convolutional_resize().
Creates and returns a copy of a specified layer.
[in] | src | The source layer. |
Definition at line 239 of file neural_layer.h.
References LayerVtbl::layer_impl_copy, and Layer::layer_vptr.
Referenced by neural_copy(), neural_layer_lstm_copy(), and neural_layer_recurrent_copy().
void layer_defaults | ( | struct Layer * | l | ) |
Initialises a layer to default values.
[in] | l | The layer to initialise. |
Definition at line 413 of file neural_layer.c.
References Layer::bias_updates, Layer::biases, Layer::c, Layer::cell, Layer::channels, Layer::dc, Layer::decay, Layer::delta, Layer::eta, Layer::eta_max, Layer::eta_min, Layer::f, Layer::function, Layer::g, Layer::h, Layer::height, Layer::i, Layer::indexes, Layer::input_layer, Layer::layer_vptr, Layer::max_neuron_grow, Layer::max_outputs, Layer::momentum, Layer::mu, Layer::n_active, Layer::n_biases, Layer::n_filters, Layer::n_inputs, Layer::n_outputs, Layer::n_weights, Layer::o, Layer::options, Layer::out_c, Layer::out_h, Layer::out_w, Layer::output, Layer::output_layer, Layer::pad, Layer::prev_cell, Layer::prev_state, Layer::probability, Layer::recurrent_function, Layer::scale, Layer::self_layer, Layer::size, Layer::state, Layer::stride, Layer::temp, Layer::temp2, Layer::temp3, Layer::type, Layer::uf, Layer::ug, Layer::ui, Layer::uo, Layer::weight_active, Layer::weight_updates, Layer::weights, Layer::wf, Layer::wg, Layer::wi, Layer::width, and Layer::wo.
Referenced by layer_init(), layer_load(), neural_layer_avgpool_copy(), neural_layer_connected_copy(), neural_layer_convolutional_copy(), neural_layer_dropout_copy(), neural_layer_lstm_copy(), neural_layer_maxpool_copy(), neural_layer_noise_copy(), neural_layer_recurrent_copy(), neural_layer_softmax_copy(), and neural_layer_upsample_copy().
void layer_ensure_input_represention | ( | struct Layer * | l | ) |
Ensures that each neuron is connected to at least one input and each input is connected to at least one neuron.
[in] | l | A neural network layer. |
Definition at line 204 of file neural_layer.c.
References Layer::n_active, Layer::n_inputs, Layer::n_outputs, rand_normal(), rand_uniform_int(), Layer::weight_active, WEIGHT_SD, and Layer::weights.
Referenced by neural_layer_connected_mutate(), and neural_layer_connected_resize().
|
static |
Forward propagates an input through the layer.
[in] | l | Layer to be forward propagated. |
[in] | net | Network containing the layer. |
[in] | input | Input to the layer. |
Definition at line 181 of file neural_layer.h.
References LayerVtbl::layer_impl_forward, and Layer::layer_vptr.
Referenced by neural_layer_lstm_forward(), neural_layer_recurrent_forward(), and neural_propagate().
|
static |
Frees the memory used by the layer.
[in] | l | The layer to be freed. |
Definition at line 249 of file neural_layer.h.
References LayerVtbl::layer_impl_free, and Layer::layer_vptr.
Referenced by neural_free(), neural_layer_lstm_free(), neural_layer_recurrent_free(), and neural_remove().
void layer_guard_biases | ( | const struct Layer * | l | ) |
Check number of biases is within bounds.
[in] | l | Layer to check. |
Definition at line 581 of file neural_layer.c.
References layer_print(), Layer::n_biases, and N_OUTPUTS_MAX.
Referenced by guard_malloc().
void layer_guard_outputs | ( | const struct Layer * | l | ) |
Check number of outputs is within bounds.
[in] | l | Layer to check. |
Definition at line 595 of file neural_layer.c.
References layer_print(), Layer::n_outputs, and N_OUTPUTS_MAX.
Referenced by guard_malloc(), layer_add_neurons(), malloc_layer_arrays(), and realloc_layer_arrays().
void layer_guard_weights | ( | const struct Layer * | l | ) |
Check number of weights is within bounds.
[in] | l | Layer to check. |
Definition at line 609 of file neural_layer.c.
References layer_print(), Layer::n_weights, and N_WEIGHTS_MAX.
Referenced by guard_malloc(), layer_add_neurons(), and malloc_layer_arrays().
Creates and initialises a new layer.
[in] | args | Layer parameters used to initialise the layer. |
Definition at line 356 of file neural_layer.h.
References layer_defaults(), LayerVtbl::layer_impl_init, layer_set_vptr(), Layer::layer_vptr, Layer::type, and ArgsLayer::type.
Referenced by neural_create(), neural_layer_lstm_init(), neural_layer_recurrent_init(), pred_neural_ae_to_classifier(), and pred_neural_expand().
void layer_init_eta | ( | struct Layer * | l | ) |
Initialises a layer's gradient descent rate.
[in] | l | The layer to initialise. |
Definition at line 399 of file neural_layer.c.
References Layer::eta, Layer::eta_max, Layer::eta_min, LAYER_EVOLVE_ETA, Layer::options, and rand_uniform().
Referenced by neural_layer_connected_init(), and neural_layer_convolutional_init().
|
static |
Returns a json formatted string representation of a layer.
[in] | l | The layer to be returned. |
[in] | return_weights | Whether to return the weights. |
Definition at line 281 of file neural_layer.h.
References LayerVtbl::layer_impl_json_export, and Layer::layer_vptr.
Referenced by neural_json_export().
|
static |
Reads the layer from a file.
[in] | l | The layer to be read. |
[in] | fp | Pointer to the file to be read. |
Definition at line 387 of file neural_layer.h.
References layer_defaults(), LayerVtbl::layer_impl_load, layer_set_vptr(), Layer::layer_vptr, and Layer::type.
Referenced by neural_layer_lstm_load(), neural_layer_recurrent_load(), and neural_load().
|
static |
Performs layer mutation.
[in] | l | The layer to mutate. |
Definition at line 216 of file neural_layer.h.
References LayerVtbl::layer_impl_mutate, and Layer::layer_vptr.
Referenced by neural_mutate().
bool layer_mutate_connectivity | ( | struct Layer * | l, |
const double | mu_enable, | ||
const double | mu_disable | ||
) |
Mutates a layer's connectivity by zeroing weights.
[in] | l | The neural network layer to mutate. |
[in] | mu_enable | Probability of enabling a currently disabled weight. |
[in] | mu_disable | Probability of disabling a currently enabled weight. |
Definition at line 176 of file neural_layer.c.
References Layer::n_active, Layer::n_inputs, Layer::n_outputs, Layer::n_weights, rand_normal(), rand_uniform(), Layer::weight_active, WEIGHT_SD, and Layer::weights.
Referenced by mutate_connectivity(), neural_layer_connected_mutate(), and neural_layer_convolutional_mutate().
bool layer_mutate_eta | ( | struct Layer * | l, |
const double | mu | ||
) |
Mutates the gradient descent rate of a neural layer.
[in] | l | The neural network layer to mutate. |
[in] | mu | The rate of mutation. |
Definition at line 88 of file neural_layer.c.
References clamp(), Layer::eta, Layer::eta_max, Layer::eta_min, and rand_normal().
Referenced by mutate_eta(), neural_layer_connected_mutate(), and neural_layer_convolutional_mutate().
bool layer_mutate_functions | ( | struct Layer * | l, |
const double | mu | ||
) |
Mutates a layer's activation function by random selection.
[in] | l | The neural network layer to mutate. |
[in] | mu | The rate of mutation. |
Definition at line 283 of file neural_layer.c.
References Layer::function, LSTM, NUM_ACTIVATIONS, rand_uniform(), rand_uniform_int(), Layer::recurrent_function, and Layer::type.
Referenced by mutate_functions(), neural_layer_connected_mutate(), neural_layer_convolutional_mutate(), and neural_layer_lstm_mutate().
int layer_mutate_neurons | ( | const struct Layer * | l, |
const double | mu | ||
) |
Returns the number of neurons to add or remove from a layer.
[in] | l | The neural network layer to mutate. |
[in] | mu | The rate of mutation. |
Definition at line 106 of file neural_layer.c.
References clamp(), Layer::max_neuron_grow, Layer::max_outputs, Layer::n_outputs, rand_normal(), and rand_uniform().
Referenced by mutate_neurons(), and neural_layer_connected_mutate().
bool layer_mutate_weights | ( | struct Layer * | l, |
const double | mu | ||
) |
Mutates a layer's weights and biases by adding random numbers from a Gaussian normal distribution with zero mean and standard deviation equal to the mutation rate.
[in] | l | The neural network layer to mutate. |
[in] | mu | The rate of mutation. |
Definition at line 252 of file neural_layer.c.
References Layer::biases, clamp(), Layer::n_biases, Layer::n_weights, rand_normal(), Layer::weight_active, WEIGHT_MAX, WEIGHT_MIN, and Layer::weights.
Referenced by mutate_weights(), neural_layer_connected_mutate(), and neural_layer_convolutional_mutate().
|
static |
Returns the outputs of a layer.
[in] | l | The layer whose outputs are to be returned. |
Definition at line 169 of file neural_layer.h.
References LayerVtbl::layer_impl_output, and Layer::layer_vptr.
Referenced by neural_output(), neural_outputs(), and neural_propagate().
|
static |
Prints the layer.
[in] | l | The layer to be printed. |
[in] | print_weights | Whether to print the weights. |
Definition at line 270 of file neural_layer.h.
References LayerVtbl::layer_impl_print, and Layer::layer_vptr.
Referenced by get_workspace_size(), layer_guard_biases(), layer_guard_outputs(), layer_guard_weights(), max_pool(), and neural_layer_connected_resize().
|
static |
Randomises a layer.
[in] | l | The layer to be randomised. |
Definition at line 259 of file neural_layer.h.
References LayerVtbl::layer_impl_rand, and Layer::layer_vptr.
Referenced by neural_layer_lstm_rand(), neural_layer_recurrent_rand(), and neural_rand().
bool layer_receives_images | ( | const int | type | ) |
Returns a whether a layer type expects images as input.
[in] | type | Integer representation of a layer type. |
Definition at line 521 of file neural_layer.c.
References AVGPOOL, CONVOLUTIONAL, MAXPOOL, and UPSAMPLE.
Referenced by layer_args_json_export_inputs(), and layer_args_validate_inputs().
Resizes a layer using the previous layer's inputs.
[in] | l | The layer to mutate. |
[in] | prev | The layer prior to the one being mutated. |
Definition at line 228 of file neural_layer.h.
References LayerVtbl::layer_impl_resize, and Layer::layer_vptr.
Referenced by mutate_neurons(), neural_layer_lstm_resize(), neural_layer_recurrent_resize(), neural_mutate(), and neural_resize().
|
static |
Writes the layer to a file.
[in] | l | The layer to be written. |
[in] | fp | Pointer to the file to be written. |
Definition at line 373 of file neural_layer.h.
References LayerVtbl::layer_impl_save, Layer::layer_vptr, and Layer::type.
Referenced by neural_layer_lstm_save(), neural_layer_recurrent_save(), and neural_save().
void layer_set_vptr | ( | struct Layer * | l | ) |
Sets a neural network layer's functions to the implementations.
[in] | l | The neural network layer to set. |
Definition at line 42 of file neural_layer.c.
References AVGPOOL, CONNECTED, CONVOLUTIONAL, DROPOUT, layer_avgpool_vtbl, layer_connected_vtbl, layer_convolutional_vtbl, layer_dropout_vtbl, layer_lstm_vtbl, layer_maxpool_vtbl, layer_noise_vtbl, layer_recurrent_vtbl, layer_softmax_vtbl, layer_upsample_vtbl, Layer::layer_vptr, LSTM, MAXPOOL, NOISE, RECURRENT, SOFTMAX, Layer::type, and UPSAMPLE.
Referenced by layer_init(), and layer_load().
int layer_type_as_int | ( | const char * | type | ) |
Returns the integer representation of a layer type given a name.
[in] | type | String representation of a layer type. |
Definition at line 540 of file neural_layer.c.
References AVGPOOL, CONNECTED, CONVOLUTIONAL, DROPOUT, LSTM, MAXPOOL, NOISE, RECURRENT, SOFTMAX, STRING_AVGPOOL, STRING_CONNECTED, STRING_CONVOLUTIONAL, STRING_DROPOUT, STRING_LSTM, STRING_MAXPOOL, STRING_NOISE, STRING_RECURRENT, STRING_SOFTMAX, STRING_UPSAMPLE, and UPSAMPLE.
Referenced by layer_args_json_import().
const char* layer_type_as_string | ( | const int | type | ) |
Returns a string representation of a layer type from an integer.
[in] | type | Integer representation of a layer type. |
Definition at line 486 of file neural_layer.c.
References AVGPOOL, CONNECTED, CONVOLUTIONAL, DROPOUT, LSTM, MAXPOOL, NOISE, RECURRENT, SOFTMAX, STRING_AVGPOOL, STRING_CONNECTED, STRING_CONVOLUTIONAL, STRING_DROPOUT, STRING_LSTM, STRING_MAXPOOL, STRING_NOISE, STRING_RECURRENT, STRING_SOFTMAX, STRING_UPSAMPLE, and UPSAMPLE.
Referenced by layer_args_json_export().
|
static |
Updates the weights and biases of a layer.
[in] | l | The layer to be updated. |
Definition at line 205 of file neural_layer.h.
References LayerVtbl::layer_impl_update, and Layer::layer_vptr.
Referenced by neural_layer_lstm_update(), neural_layer_recurrent_update(), and neural_learn().
void layer_weight_clamp | ( | const struct Layer * | l | ) |
Clamps a layer's weights and biases in range [WEIGHT_MIN, WEIGHT_MAX].
[in] | l | The neural network layer to clamp. |
Definition at line 365 of file neural_layer.c.
References Layer::biases, clamp(), Layer::n_biases, Layer::n_weights, Layer::weight_active, WEIGHT_MAX, WEIGHT_MIN, and Layer::weights.
Referenced by neural_layer_connected_update(), and neural_layer_convolutional_update().
char* layer_weight_json | ( | const struct Layer * | l, |
const bool | return_weights | ||
) |
Returns a json formatted string representation of a layer's weights.
[in] | l | The layer to return. |
[in] | return_weights | Whether to return the values of weights and biases. |
Definition at line 324 of file neural_layer.c.
References Layer::biases, Layer::n_active, Layer::n_biases, Layer::n_weights, and Layer::weights.
Referenced by layer_weight_print(), neural_layer_connected_json_export(), neural_layer_convolutional_json_export(), neural_layer_lstm_json_export(), and neural_layer_recurrent_json_export().
void layer_weight_print | ( | const struct Layer * | l, |
const bool | print_weights | ||
) |
Prints a layer's weights and biases.
[in] | l | The neural network layer to print. |
[in] | print_weights | Whether to print each individual weight and bias. |
Definition at line 309 of file neural_layer.c.
References layer_weight_json().
void layer_weight_rand | ( | struct Layer * | l | ) |
Randomises a layer's weights and biases.
[in] | l | The neural network layer to randomise. |
Definition at line 348 of file neural_layer.c.
References Layer::biases, Layer::n_active, Layer::n_biases, Layer::n_weights, rand_normal(), Layer::weight_active, WEIGHT_SD_RAND, and Layer::weights.
Referenced by neural_layer_connected_rand(), and neural_layer_convolutional_rand().