XCSF
1.4.7
XCSF learning classifier system
|
An implementation of a 2D maxpooling layer. More...
#include "neural_layer_maxpool.h"
#include "neural_activations.h"
#include "utils.h"
#include <float.h>
Go to the source code of this file.
Functions | |
static void | malloc_layer_arrays (struct Layer *l) |
Allocate memory used by a maxpooling layer. More... | |
static void | realloc_layer_arrays (struct Layer *l) |
Resize memory used by a maxpooling layer. More... | |
void | neural_layer_maxpool_init (struct Layer *l, const struct ArgsLayer *args) |
Initialises a 2D maxpooling layer. More... | |
struct Layer * | neural_layer_maxpool_copy (const struct Layer *src) |
Initialises and creates a copy of one maxpooling layer from another. More... | |
void | neural_layer_maxpool_free (const struct Layer *l) |
Free memory used by a maxpooling layer. More... | |
void | neural_layer_maxpool_rand (struct Layer *l) |
Dummy function since maxpooling layers have no weights. More... | |
static int | max_pool (const struct Layer *l, const double *input, const int i, const int j, const int k) |
Returns the index of the maximum input value corresponding to a specified output height, width, and channel for a maxpooling layer. More... | |
void | neural_layer_maxpool_forward (const struct Layer *l, const struct Net *net, const double *input) |
Forward propagates a maxpooling layer. More... | |
void | neural_layer_maxpool_backward (const struct Layer *l, const struct Net *net, const double *input, double *delta) |
Backward propagates a maxpooling layer. More... | |
void | neural_layer_maxpool_update (const struct Layer *l) |
Dummy function since a maxpooling layer has no weights. More... | |
bool | neural_layer_maxpool_mutate (struct Layer *l) |
Dummy function since a maxpooling layer cannot be mutated. More... | |
void | neural_layer_maxpool_resize (struct Layer *l, const struct Layer *prev) |
Resizes a maxpooling layer if the previous layer has changed size. More... | |
double * | neural_layer_maxpool_output (const struct Layer *l) |
Returns the output from a maxpooling layer. More... | |
void | neural_layer_maxpool_print (const struct Layer *l, const bool print_weights) |
Prints a maxpooling layer. More... | |
char * | neural_layer_maxpool_json_export (const struct Layer *l, const bool return_weights) |
Returns a json formatted string representation of a maxpooling layer. More... | |
size_t | neural_layer_maxpool_save (const struct Layer *l, FILE *fp) |
Writes a maxpooling layer to a file. More... | |
size_t | neural_layer_maxpool_load (struct Layer *l, FILE *fp) |
Reads a maxpooling layer from a file. More... | |
An implementation of a 2D maxpooling layer.
Definition in file neural_layer_maxpool.c.
|
static |
Allocate memory used by a maxpooling layer.
[in] | l | The layer to be allocated memory. |
Definition at line 34 of file neural_layer_maxpool.c.
References Layer::delta, Layer::indexes, layer_guard_outputs(), Layer::n_outputs, and Layer::output.
Referenced by neural_layer_maxpool_copy(), neural_layer_maxpool_init(), and neural_layer_maxpool_load().
|
static |
Returns the index of the maximum input value corresponding to a specified output height, width, and channel for a maxpooling layer.
[in] | l | A maxpooling layer. |
[in] | input | The input to perform a maxpooling operation. |
[in] | i | Output height index. |
[in] | j | Output width index. |
[in] | k | Output channel index. |
Definition at line 143 of file neural_layer_maxpool.c.
References Layer::height, Layer::i, layer_print(), Layer::n_inputs, Layer::pad, Layer::size, Layer::stride, and Layer::width.
Referenced by neural_layer_maxpool_forward().
void neural_layer_maxpool_backward | ( | const struct Layer * | l, |
const struct Net * | net, | ||
const double * | input, | ||
double * | delta | ||
) |
Backward propagates a maxpooling layer.
[in] | l | The layer to backward propagate. |
[in] | net | Network containing the layer. |
[in] | input | The input to the layer. |
[out] | delta | The previous layer's error. |
Definition at line 203 of file neural_layer_maxpool.c.
References Layer::delta, Layer::i, Layer::indexes, and Layer::n_outputs.
Initialises and creates a copy of one maxpooling layer from another.
[in] | src | The source layer. |
Definition at line 84 of file neural_layer_maxpool.c.
References Layer::channels, Layer::height, layer_defaults(), Layer::layer_vptr, malloc_layer_arrays(), Layer::max_outputs, MAXPOOL, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::pad, Layer::size, Layer::stride, Layer::type, and Layer::width.
void neural_layer_maxpool_forward | ( | const struct Layer * | l, |
const struct Net * | net, | ||
const double * | input | ||
) |
Forward propagates a maxpooling layer.
[in] | l | Layer to forward propagate. |
[in] | net | Network containing the layer. |
[in] | input | Input to the layer. |
Definition at line 177 of file neural_layer_maxpool.c.
References Layer::channels, Layer::i, Layer::indexes, max_pool(), Layer::n_outputs, Layer::out_h, Layer::out_w, and Layer::output.
void neural_layer_maxpool_free | ( | const struct Layer * | l | ) |
Free memory used by a maxpooling layer.
[in] | l | The layer to be freed. |
Definition at line 115 of file neural_layer_maxpool.c.
References Layer::delta, Layer::indexes, and Layer::output.
Initialises a 2D maxpooling layer.
[in] | l | Layer to initialise. |
[in] | args | Parameters to initialise the layer. |
Definition at line 61 of file neural_layer_maxpool.c.
References Layer::channels, ArgsLayer::channels, Layer::height, ArgsLayer::height, malloc_layer_arrays(), Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::pad, ArgsLayer::pad, Layer::size, ArgsLayer::size, Layer::stride, ArgsLayer::stride, Layer::width, and ArgsLayer::width.
char* neural_layer_maxpool_json_export | ( | const struct Layer * | l, |
const bool | return_weights | ||
) |
Returns a json formatted string representation of a maxpooling layer.
[in] | l | The layer to return. |
[in] | return_weights | Whether to return the values of weights and biases. |
Definition at line 292 of file neural_layer_maxpool.c.
References Layer::channels, Layer::height, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::pad, Layer::size, Layer::stride, and Layer::width.
Referenced by neural_layer_maxpool_print().
size_t neural_layer_maxpool_load | ( | struct Layer * | l, |
FILE * | fp | ||
) |
Reads a maxpooling layer from a file.
[in] | l | The layer to load. |
[in] | fp | Pointer to the file to be read. |
Definition at line 346 of file neural_layer_maxpool.c.
References Layer::channels, Layer::height, malloc_layer_arrays(), Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::pad, Layer::size, Layer::stride, and Layer::width.
bool neural_layer_maxpool_mutate | ( | struct Layer * | l | ) |
Dummy function since a maxpooling layer cannot be mutated.
[in] | l | A maxpooling layer. |
Definition at line 231 of file neural_layer_maxpool.c.
double* neural_layer_maxpool_output | ( | const struct Layer * | l | ) |
Returns the output from a maxpooling layer.
[in] | l | The layer whose output to return. |
Definition at line 266 of file neural_layer_maxpool.c.
References Layer::output.
void neural_layer_maxpool_print | ( | const struct Layer * | l, |
const bool | print_weights | ||
) |
Prints a maxpooling layer.
[in] | l | The layer to print. |
[in] | print_weights | Whether to print the values of weights and biases. |
Definition at line 277 of file neural_layer_maxpool.c.
References neural_layer_maxpool_json_export().
void neural_layer_maxpool_rand | ( | struct Layer * | l | ) |
Dummy function since maxpooling layers have no weights.
[in] | l | A maxpooling layer. |
Definition at line 127 of file neural_layer_maxpool.c.
Resizes a maxpooling layer if the previous layer has changed size.
[in] | l | The layer to resize. |
[in] | prev | The layer previous to the one being resized. |
Definition at line 243 of file neural_layer_maxpool.c.
References Layer::c, Layer::channels, Layer::h, Layer::height, Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::pad, realloc_layer_arrays(), Layer::size, Layer::stride, and Layer::width.
size_t neural_layer_maxpool_save | ( | const struct Layer * | l, |
FILE * | fp | ||
) |
Writes a maxpooling layer to a file.
[in] | l | The layer to save. |
[in] | fp | Pointer to the file to be written. |
Definition at line 321 of file neural_layer_maxpool.c.
References Layer::channels, Layer::height, Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, Layer::out_c, Layer::out_h, Layer::out_w, Layer::pad, Layer::size, Layer::stride, and Layer::width.
void neural_layer_maxpool_update | ( | const struct Layer * | l | ) |
Dummy function since a maxpooling layer has no weights.
[in] | l | A maxpooling layer. |
Definition at line 220 of file neural_layer_maxpool.c.
|
static |
Resize memory used by a maxpooling layer.
[in] | l | The layer to be allocated memory. |
Definition at line 47 of file neural_layer_maxpool.c.
References Layer::delta, Layer::indexes, layer_guard_outputs(), Layer::n_outputs, and Layer::output.
Referenced by neural_layer_maxpool_resize().