XCSF  1.4.7
XCSF learning classifier system
neural_layer_connected.h File Reference

An implementation of a fully-connected layer of perceptrons. More...

#include "neural_layer.h"
Include dependency graph for neural_layer_connected.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void neural_layer_connected_init (struct Layer *l, const struct ArgsLayer *args)
 Initialises a fully-connected layer. More...
 
struct Layerneural_layer_connected_copy (const struct Layer *src)
 Initialises and creates a copy of one connected layer from another. More...
 
void neural_layer_connected_rand (struct Layer *l)
 Randomises a connected layer weights. More...
 
void neural_layer_connected_forward (const struct Layer *l, const struct Net *net, const double *input)
 Forward propagates a connected layer. More...
 
void neural_layer_connected_backward (const struct Layer *l, const struct Net *net, const double *input, double *delta)
 Backward propagates a connected layer. More...
 
void neural_layer_connected_update (const struct Layer *l)
 Updates the weights and biases of a connected layer. More...
 
void neural_layer_connected_print (const struct Layer *l, const bool print_weights)
 Prints a connected layer. More...
 
bool neural_layer_connected_mutate (struct Layer *l)
 Mutates a connected layer. More...
 
void neural_layer_connected_free (const struct Layer *l)
 Free memory used by a connected layer. More...
 
double * neural_layer_connected_output (const struct Layer *l)
 Returns the output from a connected layer. More...
 
size_t neural_layer_connected_save (const struct Layer *l, FILE *fp)
 Writes a connected layer to a file. More...
 
size_t neural_layer_connected_load (struct Layer *l, FILE *fp)
 Reads a connected layer from a file. More...
 
void neural_layer_connected_resize (struct Layer *l, const struct Layer *prev)
 Resizes a connected layer if the previous layer has changed size. More...
 
char * neural_layer_connected_json_export (const struct Layer *l, const bool return_weights)
 Returns a json formatted string representation of a connected layer. More...
 

Variables

static struct LayerVtbl const layer_connected_vtbl
 Neural connected layer implemented functions. More...
 

Detailed Description

An implementation of a fully-connected layer of perceptrons.

Author
Richard Preen rpree.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om
Date
2016–2021.

Definition in file neural_layer_connected.h.

Function Documentation

◆ neural_layer_connected_backward()

void neural_layer_connected_backward ( const struct Layer l,
const struct Net net,
const double *  input,
double *  delta 
)

Backward propagates a connected layer.

Parameters
[in]lThe layer to backward propagate.
[in]netNetwork containing the layer.
[in]inputThe input to the layer.
[out]deltaThe previous layer's error.

Definition at line 196 of file neural_layer_connected.c.

References Layer::bias_updates, blas_axpy(), blas_gemm(), Layer::c, Layer::delta, Layer::function, LAYER_SGD_WEIGHTS, Layer::n_inputs, Layer::n_outputs, neural_gradient_array(), Layer::options, Layer::state, Layer::weight_updates, and Layer::weights.

Here is the call graph for this function:

◆ neural_layer_connected_copy()

struct Layer* neural_layer_connected_copy ( const struct Layer src)

Initialises and creates a copy of one connected layer from another.

Parameters
[in]srcThe source layer.
Returns
A pointer to the new layer.

Definition at line 122 of file neural_layer_connected.c.

References Layer::biases, CONNECTED, Layer::decay, Layer::eta, Layer::eta_max, Layer::eta_min, Layer::function, layer_defaults(), Layer::layer_vptr, malloc_layer_arrays(), Layer::max_neuron_grow, Layer::max_outputs, Layer::momentum, Layer::mu, Layer::n_active, Layer::n_biases, Layer::n_inputs, N_MU, Layer::n_outputs, Layer::n_weights, Layer::options, Layer::out_c, Layer::out_h, Layer::out_w, Layer::type, Layer::weight_active, and Layer::weights.

Here is the call graph for this function:

◆ neural_layer_connected_forward()

void neural_layer_connected_forward ( const struct Layer l,
const struct Net net,
const double *  input 
)

Forward propagates a connected layer.

Parameters
[in]lLayer to forward propagate.
[in]netNetwork containing the layer.
[in]inputInput to the layer.

Definition at line 174 of file neural_layer_connected.c.

References Layer::biases, blas_gemm(), Layer::c, Layer::function, Layer::n_inputs, Layer::n_outputs, neural_activate_array(), Layer::output, Layer::state, and Layer::weights.

Here is the call graph for this function:

◆ neural_layer_connected_free()

void neural_layer_connected_free ( const struct Layer l)

Free memory used by a connected layer.

Parameters
[in]lThe layer to be freed.

Definition at line 103 of file neural_layer_connected.c.

References Layer::bias_updates, Layer::biases, Layer::delta, Layer::mu, Layer::output, Layer::state, Layer::weight_active, Layer::weight_updates, and Layer::weights.

◆ neural_layer_connected_init()

void neural_layer_connected_init ( struct Layer l,
const struct ArgsLayer args 
)

◆ neural_layer_connected_json_export()

char* neural_layer_connected_json_export ( const struct Layer l,
const bool  return_weights 
)

Returns a json formatted string representation of a connected layer.

Parameters
[in]lThe layer to return.
[in]return_weightsWhether to returnprint the values of weights and biases.
Returns
String encoded in json format.

Definition at line 354 of file neural_layer_connected.c.

References Layer::eta, Layer::function, layer_weight_json(), Layer::mu, Layer::n_inputs, N_MU, Layer::n_outputs, neural_activation_string(), and Layer::weights.

Referenced by neural_layer_connected_print().

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

◆ neural_layer_connected_load()

size_t neural_layer_connected_load ( struct Layer l,
FILE *  fp 
)

Reads a connected layer from a file.

Parameters
[in]lThe layer to load.
[in]fpPointer to the file to be read.
Returns
The number of elements read.

Definition at line 415 of file neural_layer_connected.c.

References Layer::bias_updates, Layer::biases, Layer::decay, Layer::eta, Layer::eta_max, Layer::eta_min, Layer::function, malloc_layer_arrays(), Layer::max_neuron_grow, Layer::max_outputs, Layer::momentum, Layer::mu, Layer::n_active, Layer::n_biases, Layer::n_inputs, N_MU, Layer::n_outputs, Layer::n_weights, Layer::options, Layer::out_c, Layer::out_h, Layer::out_w, Layer::weight_active, Layer::weight_updates, and Layer::weights.

Here is the call graph for this function:

◆ neural_layer_connected_mutate()

bool neural_layer_connected_mutate ( struct Layer l)

Mutates a connected layer.

Parameters
[in]lThe layer to mutate.
Returns
Whether any alterations were made.

Definition at line 292 of file neural_layer_connected.c.

References layer_add_neurons(), layer_ensure_input_represention(), LAYER_EVOLVE_CONNECT, LAYER_EVOLVE_ETA, LAYER_EVOLVE_FUNCTIONS, LAYER_EVOLVE_NEURONS, LAYER_EVOLVE_WEIGHTS, layer_mutate_connectivity(), layer_mutate_eta(), layer_mutate_functions(), layer_mutate_neurons(), layer_mutate_weights(), Layer::mu, MU_TYPE, N_MU, Layer::options, and sam_adapt().

Here is the call graph for this function:

◆ neural_layer_connected_output()

double* neural_layer_connected_output ( const struct Layer l)

Returns the output from a connected layer.

Parameters
[in]lThe layer whose output to return.
Returns
The layer output.

Definition at line 328 of file neural_layer_connected.c.

References Layer::output.

◆ neural_layer_connected_print()

void neural_layer_connected_print ( const struct Layer l,
const bool  print_weights 
)

Prints a connected layer.

Parameters
[in]lThe layer to print.
[in]print_weightsWhether to print the values of weights and biases.

Definition at line 339 of file neural_layer_connected.c.

References neural_layer_connected_json_export().

Here is the call graph for this function:

◆ neural_layer_connected_rand()

void neural_layer_connected_rand ( struct Layer l)

Randomises a connected layer weights.

Parameters
[in]lThe layer to randomise.

Definition at line 162 of file neural_layer_connected.c.

References layer_weight_rand().

Here is the call graph for this function:

◆ neural_layer_connected_resize()

void neural_layer_connected_resize ( struct Layer l,
const struct Layer prev 
)

Resizes a connected layer if the previous layer has changed size.

Parameters
[in]lThe layer to resize.
[in]prevThe layer previous to the one being resized.

Definition at line 246 of file neural_layer_connected.c.

References Layer::i, layer_calc_n_active(), layer_ensure_input_represention(), LAYER_EVOLVE_CONNECT, layer_print(), Layer::n_inputs, Layer::n_outputs, Layer::n_weights, N_WEIGHTS_MAX, Layer::options, rand_normal(), Layer::weight_active, WEIGHT_SD, Layer::weight_updates, and Layer::weights.

Here is the call graph for this function:

◆ neural_layer_connected_save()

size_t neural_layer_connected_save ( const struct Layer l,
FILE *  fp 
)

Writes a connected layer to a file.

Parameters
[in]lThe layer to save.
[in]fpPointer to the file to be written.
Returns
The number of elements written.

Definition at line 382 of file neural_layer_connected.c.

References Layer::bias_updates, Layer::biases, Layer::decay, Layer::eta, Layer::eta_max, Layer::eta_min, Layer::function, Layer::max_neuron_grow, Layer::max_outputs, Layer::momentum, Layer::mu, Layer::n_active, Layer::n_biases, Layer::n_inputs, N_MU, Layer::n_outputs, Layer::n_weights, Layer::options, Layer::weight_active, Layer::weight_updates, and Layer::weights.

◆ neural_layer_connected_update()

void neural_layer_connected_update ( const struct Layer l)

Updates the weights and biases of a connected layer.

Parameters
[in]lThe layer to update.

Definition at line 225 of file neural_layer_connected.c.

References Layer::bias_updates, Layer::biases, blas_axpy(), blas_scal(), Layer::decay, Layer::eta, LAYER_SGD_WEIGHTS, layer_weight_clamp(), Layer::momentum, Layer::n_biases, Layer::n_weights, Layer::options, Layer::weight_updates, and Layer::weights.

Here is the call graph for this function:

Variable Documentation

◆ layer_connected_vtbl

struct LayerVtbl const layer_connected_vtbl
static
Initial value:
= {
}
size_t neural_layer_connected_save(const struct Layer *l, FILE *fp)
Writes a connected layer to a file.
struct Layer * neural_layer_connected_copy(const struct Layer *src)
Initialises and creates a copy of one connected layer from another.
void neural_layer_connected_print(const struct Layer *l, const bool print_weights)
Prints a connected layer.
char * neural_layer_connected_json_export(const struct Layer *l, const bool return_weights)
Returns a json formatted string representation of a connected layer.
void neural_layer_connected_rand(struct Layer *l)
Randomises a connected layer weights.
void neural_layer_connected_resize(struct Layer *l, const struct Layer *prev)
Resizes a connected layer if the previous layer has changed size.
double * neural_layer_connected_output(const struct Layer *l)
Returns the output from a connected layer.
size_t neural_layer_connected_load(struct Layer *l, FILE *fp)
Reads a connected layer from a file.
void neural_layer_connected_backward(const struct Layer *l, const struct Net *net, const double *input, double *delta)
Backward propagates a connected layer.
bool neural_layer_connected_mutate(struct Layer *l)
Mutates a connected layer.
void neural_layer_connected_forward(const struct Layer *l, const struct Net *net, const double *input)
Forward propagates a connected layer.
void neural_layer_connected_init(struct Layer *l, const struct ArgsLayer *args)
Initialises a fully-connected layer.
void neural_layer_connected_update(const struct Layer *l)
Updates the weights and biases of a connected layer.
void neural_layer_connected_free(const struct Layer *l)
Free memory used by a connected layer.

Neural connected layer implemented functions.

Definition at line 70 of file neural_layer_connected.h.

Referenced by layer_set_vptr().