XCSF  1.4.7
XCSF learning classifier system
neural_layer_dropout.c File Reference

An implementation of a dropout layer. More...

#include "neural_layer_dropout.h"
#include "neural_activations.h"
#include "utils.h"
Include dependency graph for neural_layer_dropout.c:

Go to the source code of this file.

Functions

static void malloc_layer_arrays (struct Layer *l)
 Allocate memory used by a dropout layer. More...
 
static void free_layer_arrays (const struct Layer *l)
 Free memory used by a dropout layer. More...
 
void neural_layer_dropout_init (struct Layer *l, const struct ArgsLayer *args)
 Initialises a dropout layer. More...
 
void neural_layer_dropout_free (const struct Layer *l)
 Free memory used by a dropout layer. More...
 
struct Layerneural_layer_dropout_copy (const struct Layer *src)
 Initialises and creates a copy of one dropout layer from another. More...
 
void neural_layer_dropout_rand (struct Layer *l)
 Dummy function since dropout layers have no weights. More...
 
void neural_layer_dropout_forward (const struct Layer *l, const struct Net *net, const double *input)
 Forward propagates a dropout layer. More...
 
void neural_layer_dropout_backward (const struct Layer *l, const struct Net *net, const double *input, double *delta)
 Backward propagates a dropout layer. More...
 
void neural_layer_dropout_update (const struct Layer *l)
 Dummy function since a dropout layer has no weights. More...
 
bool neural_layer_dropout_mutate (struct Layer *l)
 Dummy function since a dropout layer cannot be mutated. More...
 
void neural_layer_dropout_resize (struct Layer *l, const struct Layer *prev)
 Resizes a dropout layer if the previous layer has changed size. More...
 
double * neural_layer_dropout_output (const struct Layer *l)
 Returns the output from a dropout layer. More...
 
void neural_layer_dropout_print (const struct Layer *l, const bool print_weights)
 Prints a dropout layer. More...
 
char * neural_layer_dropout_json_export (const struct Layer *l, const bool return_weights)
 Returns a json formatted string representation of a dropout layer. More...
 
size_t neural_layer_dropout_save (const struct Layer *l, FILE *fp)
 Writes a dropout layer to a file. More...
 
size_t neural_layer_dropout_load (struct Layer *l, FILE *fp)
 Reads a dropout layer from a file. More...
 

Detailed Description

An implementation of a dropout layer.

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

Definition in file neural_layer_dropout.c.

Function Documentation

◆ free_layer_arrays()

static void free_layer_arrays ( const struct Layer l)
static

Free memory used by a dropout layer.

Parameters
[in]lThe layer to be freed.

Definition at line 46 of file neural_layer_dropout.c.

References Layer::delta, Layer::output, and Layer::state.

Referenced by neural_layer_dropout_free(), and neural_layer_dropout_resize().

Here is the caller graph for this function:

◆ malloc_layer_arrays()

static void malloc_layer_arrays ( struct Layer l)
static

Allocate memory used by a dropout layer.

Parameters
[in]lThe layer to be allocated memory.

Definition at line 33 of file neural_layer_dropout.c.

References Layer::delta, layer_guard_outputs(), Layer::n_outputs, Layer::output, and Layer::state.

Referenced by neural_layer_dropout_copy(), neural_layer_dropout_init(), neural_layer_dropout_load(), and neural_layer_dropout_resize().

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

◆ neural_layer_dropout_backward()

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

Backward propagates a dropout 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 152 of file neural_layer_dropout.c.

References Layer::delta, Layer::i, Layer::n_inputs, Layer::probability, Layer::scale, and Layer::state.

◆ neural_layer_dropout_copy()

struct Layer* neural_layer_dropout_copy ( const struct Layer src)

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

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

Definition at line 88 of file neural_layer_dropout.c.

References DROPOUT, layer_defaults(), Layer::layer_vptr, malloc_layer_arrays(), Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::probability, Layer::scale, and Layer::type.

Here is the call graph for this function:

◆ neural_layer_dropout_forward()

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

Forward propagates a dropout layer.

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

Definition at line 127 of file neural_layer_dropout.c.

References Layer::i, Layer::n_inputs, Layer::output, Layer::probability, rand_uniform(), Layer::scale, Layer::state, and Net::train.

Here is the call graph for this function:

◆ neural_layer_dropout_free()

void neural_layer_dropout_free ( const struct Layer l)

Free memory used by a dropout layer.

Parameters
[in]lThe layer to be freed.

Definition at line 77 of file neural_layer_dropout.c.

References free_layer_arrays().

Here is the call graph for this function:

◆ neural_layer_dropout_init()

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

Initialises a dropout layer.

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

Definition at line 59 of file neural_layer_dropout.c.

References ArgsLayer::channels, ArgsLayer::height, malloc_layer_arrays(), Layer::max_outputs, Layer::n_inputs, ArgsLayer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::probability, ArgsLayer::probability, Layer::scale, and ArgsLayer::width.

Here is the call graph for this function:

◆ neural_layer_dropout_json_export()

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

Returns a json formatted string representation of a dropout 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 240 of file neural_layer_dropout.c.

References Layer::n_inputs, Layer::n_outputs, and Layer::probability.

Referenced by neural_layer_dropout_print().

Here is the caller graph for this function:

◆ neural_layer_dropout_load()

size_t neural_layer_dropout_load ( struct Layer l,
FILE *  fp 
)

Reads a dropout 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 282 of file neural_layer_dropout.c.

References malloc_layer_arrays(), Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::probability, and Layer::scale.

Here is the call graph for this function:

◆ neural_layer_dropout_mutate()

bool neural_layer_dropout_mutate ( struct Layer l)

Dummy function since a dropout layer cannot be mutated.

Parameters
[in]lA dropout layer.
Returns
False.

Definition at line 184 of file neural_layer_dropout.c.

◆ neural_layer_dropout_output()

double* neural_layer_dropout_output ( const struct Layer l)

Returns the output from a dropout layer.

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

Definition at line 214 of file neural_layer_dropout.c.

References Layer::output.

◆ neural_layer_dropout_print()

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

Prints a dropout layer.

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

Definition at line 225 of file neural_layer_dropout.c.

References neural_layer_dropout_json_export().

Here is the call graph for this function:

◆ neural_layer_dropout_rand()

void neural_layer_dropout_rand ( struct Layer l)

Dummy function since dropout layers have no weights.

Parameters
[in]lA dropout layer.

Definition at line 115 of file neural_layer_dropout.c.

◆ neural_layer_dropout_resize()

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

Resizes a dropout 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 196 of file neural_layer_dropout.c.

References free_layer_arrays(), malloc_layer_arrays(), Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, and Layer::out_w.

Here is the call graph for this function:

◆ neural_layer_dropout_save()

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

Writes a dropout 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 261 of file neural_layer_dropout.c.

References Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::probability, and Layer::scale.

◆ neural_layer_dropout_update()

void neural_layer_dropout_update ( const struct Layer l)

Dummy function since a dropout layer has no weights.

Parameters
[in]lA dropout layer.

Definition at line 173 of file neural_layer_dropout.c.