XCSF  1.4.7
XCSF learning classifier system
neural_layer_softmax.h File Reference

An implementation of a softmax layer. More...

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

Go to the source code of this file.

Functions

void neural_layer_softmax_init (struct Layer *l, const struct ArgsLayer *args)
 Creates and initialises a softmax layer. More...
 
struct Layerneural_layer_softmax_copy (const struct Layer *src)
 Initialises and creates a copy of one softmax layer from another. More...
 
void neural_layer_softmax_rand (struct Layer *l)
 Dummy function since softmax layers have no weights. More...
 
void neural_layer_softmax_forward (const struct Layer *l, const struct Net *net, const double *input)
 Forward propagates a softmax layer. More...
 
void neural_layer_softmax_backward (const struct Layer *l, const struct Net *net, const double *input, double *delta)
 Backward propagates a softmax layer. More...
 
void neural_layer_softmax_update (const struct Layer *l)
 Dummy function since a softmax layer has no weights. More...
 
void neural_layer_softmax_print (const struct Layer *l, const bool print_weights)
 Prints a softmax layer. More...
 
bool neural_layer_softmax_mutate (struct Layer *l)
 Dummy function since a softmax layer cannot be mutated. More...
 
void neural_layer_softmax_free (const struct Layer *l)
 Free memory used by a softmax layer. More...
 
double * neural_layer_softmax_output (const struct Layer *l)
 Returns the output from a softmax layer. More...
 
size_t neural_layer_softmax_save (const struct Layer *l, FILE *fp)
 Writes a softmax layer to a file. More...
 
size_t neural_layer_softmax_load (struct Layer *l, FILE *fp)
 Reads a softmax layer from a file. More...
 
void neural_layer_softmax_resize (struct Layer *l, const struct Layer *prev)
 Resizes a softmax layer if the previous layer has changed size. More...
 
char * neural_layer_softmax_json_export (const struct Layer *l, const bool return_weights)
 Returns a json formatted string representation of a softmax layer. More...
 

Variables

static struct LayerVtbl const layer_softmax_vtbl
 Neural softmax layer implemented functions. More...
 

Detailed Description

An implementation of a softmax layer.

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

Definition in file neural_layer_softmax.h.

Function Documentation

◆ neural_layer_softmax_backward()

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

Backward propagates a softmax 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 142 of file neural_layer_softmax.c.

References Layer::delta, Layer::i, and Layer::n_inputs.

◆ neural_layer_softmax_copy()

struct Layer* neural_layer_softmax_copy ( const struct Layer src)

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

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

Definition at line 75 of file neural_layer_softmax.c.

References 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::scale, SOFTMAX, and Layer::type.

Here is the call graph for this function:

◆ neural_layer_softmax_forward()

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

Forward propagates a softmax layer.

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

Definition at line 113 of file neural_layer_softmax.c.

References Layer::i, Layer::n_inputs, Layer::output, and Layer::scale.

◆ neural_layer_softmax_free()

void neural_layer_softmax_free ( const struct Layer l)

Free memory used by a softmax layer.

Parameters
[in]lThe layer to be freed.

Definition at line 234 of file neural_layer_softmax.c.

References free_layer_arrays().

Here is the call graph for this function:

◆ neural_layer_softmax_init()

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

Creates and initialises a softmax layer.

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

Definition at line 57 of file neural_layer_softmax.c.

References 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::scale, and ArgsLayer::scale.

Here is the call graph for this function:

◆ neural_layer_softmax_json_export()

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

Returns a json formatted string representation of a softmax 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 185 of file neural_layer_softmax.c.

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

Referenced by neural_layer_softmax_print().

Here is the caller graph for this function:

◆ neural_layer_softmax_load()

size_t neural_layer_softmax_load ( struct Layer l,
FILE *  fp 
)

Reads a softmax 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 274 of file neural_layer_softmax.c.

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

Here is the call graph for this function:

◆ neural_layer_softmax_mutate()

bool neural_layer_softmax_mutate ( struct Layer l)

Dummy function since a softmax layer cannot be mutated.

Parameters
[in]lA softmax layer.
Returns
False.

Definition at line 205 of file neural_layer_softmax.c.

◆ neural_layer_softmax_output()

double* neural_layer_softmax_output ( const struct Layer l)

Returns the output from a softmax layer.

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

Definition at line 245 of file neural_layer_softmax.c.

References Layer::output.

◆ neural_layer_softmax_print()

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

Prints a softmax layer.

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

Definition at line 170 of file neural_layer_softmax.c.

References neural_layer_softmax_json_export().

Here is the call graph for this function:

◆ neural_layer_softmax_rand()

void neural_layer_softmax_rand ( struct Layer l)

Dummy function since softmax layers have no weights.

Parameters
[in]lA softmax layer.

Definition at line 101 of file neural_layer_softmax.c.

◆ neural_layer_softmax_resize()

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

Resizes a softmax 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 217 of file neural_layer_softmax.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_softmax_save()

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

Writes a softmax 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 257 of file neural_layer_softmax.c.

References Layer::max_outputs, Layer::n_inputs, Layer::n_outputs, and Layer::scale.

◆ neural_layer_softmax_update()

void neural_layer_softmax_update ( const struct Layer l)

Dummy function since a softmax layer has no weights.

Parameters
[in]lA softmax layer.

Definition at line 159 of file neural_layer_softmax.c.

Variable Documentation

◆ layer_softmax_vtbl

struct LayerVtbl const layer_softmax_vtbl
static
Initial value:
= {
}
double * neural_layer_softmax_output(const struct Layer *l)
Returns the output from a softmax layer.
void neural_layer_softmax_backward(const struct Layer *l, const struct Net *net, const double *input, double *delta)
Backward propagates a softmax layer.
void neural_layer_softmax_free(const struct Layer *l)
Free memory used by a softmax layer.
char * neural_layer_softmax_json_export(const struct Layer *l, const bool return_weights)
Returns a json formatted string representation of a softmax layer.
struct Layer * neural_layer_softmax_copy(const struct Layer *src)
Initialises and creates a copy of one softmax layer from another.
size_t neural_layer_softmax_load(struct Layer *l, FILE *fp)
Reads a softmax layer from a file.
void neural_layer_softmax_print(const struct Layer *l, const bool print_weights)
Prints a softmax layer.
void neural_layer_softmax_init(struct Layer *l, const struct ArgsLayer *args)
Creates and initialises a softmax layer.
size_t neural_layer_softmax_save(const struct Layer *l, FILE *fp)
Writes a softmax layer to a file.
void neural_layer_softmax_forward(const struct Layer *l, const struct Net *net, const double *input)
Forward propagates a softmax layer.
void neural_layer_softmax_update(const struct Layer *l)
Dummy function since a softmax layer has no weights.
void neural_layer_softmax_rand(struct Layer *l)
Dummy function since softmax layers have no weights.
void neural_layer_softmax_resize(struct Layer *l, const struct Layer *prev)
Resizes a softmax layer if the previous layer has changed size.
bool neural_layer_softmax_mutate(struct Layer *l)
Dummy function since a softmax layer cannot be mutated.

Neural softmax layer implemented functions.

Definition at line 69 of file neural_layer_softmax.h.

Referenced by layer_set_vptr().