XCSF  1.4.7
XCSF learning classifier system
neural_layer_recurrent.h File Reference

An implementation of a recurrent layer of perceptrons. More...

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

Go to the source code of this file.

Functions

void neural_layer_recurrent_init (struct Layer *l, const struct ArgsLayer *args)
 Initialises a recurrent layer. More...
 
struct Layerneural_layer_recurrent_copy (const struct Layer *src)
 Initialises and creates a copy of one recurrent layer from another. More...
 
void neural_layer_recurrent_rand (struct Layer *l)
 Randomises a recurrent layer weights. More...
 
void neural_layer_recurrent_forward (const struct Layer *l, const struct Net *net, const double *input)
 Forward propagates a recurrent layer. More...
 
void neural_layer_recurrent_backward (const struct Layer *l, const struct Net *net, const double *input, double *delta)
 Backward propagates a recurrent layer. More...
 
void neural_layer_recurrent_update (const struct Layer *l)
 Updates the weights and biases of a recurrent layer. More...
 
void neural_layer_recurrent_print (const struct Layer *l, const bool print_weights)
 Prints a recurrent layer. More...
 
bool neural_layer_recurrent_mutate (struct Layer *l)
 Mutates a recurrent layer. More...
 
void neural_layer_recurrent_free (const struct Layer *l)
 Free memory used by a recurrent layer. More...
 
double * neural_layer_recurrent_output (const struct Layer *l)
 Returns the output from a recurrent layer. More...
 
size_t neural_layer_recurrent_save (const struct Layer *l, FILE *fp)
 Writes a recurrent layer to a file. More...
 
size_t neural_layer_recurrent_load (struct Layer *l, FILE *fp)
 Reads a recurrent layer from a file. More...
 
void neural_layer_recurrent_resize (struct Layer *l, const struct Layer *prev)
 Resizes a recurrent layer if the previous layer has changed size. More...
 
char * neural_layer_recurrent_json_export (const struct Layer *l, const bool return_weights)
 Returns a json formatted string representation of a recurrent layer. More...
 

Variables

static struct LayerVtbl const layer_recurrent_vtbl
 Neural recurrent layer implemented functions. More...
 

Detailed Description

An implementation of a recurrent 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_recurrent.h.

Function Documentation

◆ neural_layer_recurrent_backward()

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

Backward propagates a recurrent 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 368 of file neural_layer_recurrent.c.

References Layer::delta, Layer::input_layer, layer_backward(), Layer::n_outputs, Layer::output_layer, Layer::prev_state, Layer::self_layer, and Layer::state.

Here is the call graph for this function:

◆ neural_layer_recurrent_copy()

struct Layer* neural_layer_recurrent_copy ( const struct Layer src)

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

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

Definition at line 283 of file neural_layer_recurrent.c.

References Layer::delta, Layer::eta, Layer::function, Layer::input_layer, layer_copy(), layer_defaults(), Layer::layer_vptr, malloc_layer_arrays(), Layer::max_outputs, Layer::mu, Layer::n_active, Layer::n_inputs, N_MU, Layer::n_outputs, Layer::options, Layer::out_c, Layer::out_h, Layer::out_w, Layer::output, Layer::output_layer, Layer::prev_state, RECURRENT, Layer::self_layer, and Layer::type.

Here is the call graph for this function:

◆ neural_layer_recurrent_forward()

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

Forward propagates a recurrent layer.

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

Definition at line 349 of file neural_layer_recurrent.c.

References blas_axpy(), Layer::input_layer, layer_forward(), Layer::n_outputs, Layer::output, Layer::output_layer, Layer::prev_state, Layer::self_layer, and Layer::state.

Here is the call graph for this function:

◆ neural_layer_recurrent_free()

void neural_layer_recurrent_free ( const struct Layer l)

Free memory used by a recurrent layer.

Parameters
[in]lThe layer to be freed.

Definition at line 319 of file neural_layer_recurrent.c.

References free_layer_arrays(), Layer::input_layer, layer_free(), Layer::output_layer, and Layer::self_layer.

Here is the call graph for this function:

◆ neural_layer_recurrent_init()

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

Initialises a recurrent layer.

Parameters
[in]lLayer to initialise.
[in]argsParameters to initialise the layer.

Definition at line 246 of file neural_layer_recurrent.c.

References CONNECTED, Layer::delta, Layer::eta, Layer::function, ArgsLayer::function, Layer::input_layer, layer_args_copy(), layer_args_opt(), layer_init(), LINEAR, malloc_layer_arrays(), Layer::max_outputs, Layer::mu, MU_TYPE, ArgsLayer::n_init, Layer::n_inputs, ArgsLayer::n_inputs, ArgsLayer::n_max, N_MU, Layer::n_outputs, Layer::options, Layer::out_c, Layer::out_h, Layer::out_w, Layer::output, Layer::output_layer, sam_init(), Layer::self_layer, set_layer_n_active(), set_layer_n_biases(), set_layer_n_weights(), and ArgsLayer::type.

Here is the call graph for this function:

◆ neural_layer_recurrent_json_export()

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

Returns a json formatted string representation of a recurrent layer.

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

Definition at line 458 of file neural_layer_recurrent.c.

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

Referenced by neural_layer_recurrent_print().

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

◆ neural_layer_recurrent_load()

size_t neural_layer_recurrent_load ( struct Layer l,
FILE *  fp 
)

Reads a recurrent 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 520 of file neural_layer_recurrent.c.

References Layer::eta, Layer::function, Layer::input_layer, layer_load(), malloc_layer_arrays(), malloc_layers(), Layer::max_outputs, Layer::mu, Layer::n_active, Layer::n_inputs, N_MU, Layer::n_outputs, Layer::options, Layer::out_c, Layer::out_h, Layer::out_w, Layer::output_layer, Layer::prev_state, Layer::self_layer, and Layer::state.

Here is the call graph for this function:

◆ neural_layer_recurrent_mutate()

bool neural_layer_recurrent_mutate ( struct Layer l)

Mutates a recurrent layer.

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

Definition at line 425 of file neural_layer_recurrent.c.

References Layer::mu, MU_TYPE, mutate_connectivity(), mutate_eta(), mutate_functions(), mutate_neurons(), mutate_weights(), N_MU, and sam_adapt().

Here is the call graph for this function:

◆ neural_layer_recurrent_output()

double* neural_layer_recurrent_output ( const struct Layer l)

Returns the output from a recurrent layer.

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

Definition at line 414 of file neural_layer_recurrent.c.

References Layer::output.

◆ neural_layer_recurrent_print()

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

Prints a recurrent layer.

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

Definition at line 443 of file neural_layer_recurrent.c.

References neural_layer_recurrent_json_export().

Here is the call graph for this function:

◆ neural_layer_recurrent_rand()

void neural_layer_recurrent_rand ( struct Layer l)

Randomises a recurrent layer weights.

Parameters
[in]lThe layer to randomise.

Definition at line 335 of file neural_layer_recurrent.c.

References Layer::input_layer, layer_rand(), Layer::output_layer, and Layer::self_layer.

Here is the call graph for this function:

◆ neural_layer_recurrent_resize()

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

Resizes a recurrent 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 400 of file neural_layer_recurrent.c.

References Layer::input_layer, layer_resize(), Layer::n_active, Layer::n_inputs, Layer::output_layer, and Layer::self_layer.

Here is the call graph for this function:

◆ neural_layer_recurrent_save()

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

Writes a recurrent 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 494 of file neural_layer_recurrent.c.

References Layer::eta, Layer::function, Layer::input_layer, layer_save(), Layer::max_outputs, Layer::mu, Layer::n_active, Layer::n_inputs, N_MU, Layer::n_outputs, Layer::options, Layer::output_layer, Layer::prev_state, Layer::self_layer, and Layer::state.

Here is the call graph for this function:

◆ neural_layer_recurrent_update()

void neural_layer_recurrent_update ( const struct Layer l)

Updates the weights and biases of a recurrent layer.

Parameters
[in]lThe layer to update.

Definition at line 385 of file neural_layer_recurrent.c.

References Layer::eta, Layer::input_layer, LAYER_SGD_WEIGHTS, layer_update(), Layer::options, Layer::output_layer, and Layer::self_layer.

Here is the call graph for this function:

Variable Documentation

◆ layer_recurrent_vtbl

struct LayerVtbl const layer_recurrent_vtbl
static
Initial value:
= {
}
size_t neural_layer_recurrent_save(const struct Layer *l, FILE *fp)
Writes a recurrent layer to a file.
size_t neural_layer_recurrent_load(struct Layer *l, FILE *fp)
Reads a recurrent layer from a file.
void neural_layer_recurrent_update(const struct Layer *l)
Updates the weights and biases of a recurrent layer.
void neural_layer_recurrent_resize(struct Layer *l, const struct Layer *prev)
Resizes a recurrent layer if the previous layer has changed size.
struct Layer * neural_layer_recurrent_copy(const struct Layer *src)
Initialises and creates a copy of one recurrent layer from another.
bool neural_layer_recurrent_mutate(struct Layer *l)
Mutates a recurrent layer.
void neural_layer_recurrent_rand(struct Layer *l)
Randomises a recurrent layer weights.
void neural_layer_recurrent_init(struct Layer *l, const struct ArgsLayer *args)
Initialises a recurrent layer.
char * neural_layer_recurrent_json_export(const struct Layer *l, const bool return_weights)
Returns a json formatted string representation of a recurrent layer.
double * neural_layer_recurrent_output(const struct Layer *l)
Returns the output from a recurrent layer.
void neural_layer_recurrent_free(const struct Layer *l)
Free memory used by a recurrent layer.
void neural_layer_recurrent_forward(const struct Layer *l, const struct Net *net, const double *input)
Forward propagates a recurrent layer.
void neural_layer_recurrent_backward(const struct Layer *l, const struct Net *net, const double *input, double *delta)
Backward propagates a recurrent layer.
void neural_layer_recurrent_print(const struct Layer *l, const bool print_weights)
Prints a recurrent layer.

Neural recurrent layer implemented functions.

Definition at line 70 of file neural_layer_recurrent.h.

Referenced by layer_set_vptr().