Deep Neuronal Filter
Layer Class Reference

This is the class for creating layers that are contained inside the Net class. More...

#include <Layer.h>

Public Types

enum  whichGradient { exploding = 0, average = 1, vanishing = 2 }
 Options for what gradient of a chosen error to monitor.
 

Public Member Functions

 Layer (int _nNeurons, int _nInputs, int _subject, string _trial)
 Constructor for Layer: it initialises the neurons internally. More...
 
 ~Layer ()
 Destructor De-allocated any memory.
 
void initLayer (int _layerIndex, Neuron::weightInitMethod _wim, Neuron::biasInitMethod _bim, Neuron::actMethod _am)
 Initialises each layer with specific methods for weight/bias initialisation and activation function of neurons. More...
 
void setlearningRate (double _w_learningRate, double _b_learningRate)
 Sets the learning rate. More...
 
void setInputs (const double *_inputs, const double scale=1.0, const unsigned int offset=0, const int n=-1)
 Sets the inputs to all neurons in the first hidden layer only. More...
 
void propInputs (int _index, double _value)
 Sets the inputs to all neurons in the deeper layers (excluding the first hidden layer) More...
 
void calcOutputs ()
 Demands that all neurons in this layer calculate their output.
 
void setError (double _error)
 Sets the error to be propagated backward at all neurons in the output layer only. More...
 
double getGradient (whichGradient _whichGradient)
 Allows for accessing the error that propagates backward in the network. More...
 
void updateWeights ()
 Requests that all neurons perform one iteration of learning.
 
NeurongetNeuron (int _neuronIndex)
 Allows access to a specific neuron. More...
 
int getnNeurons ()
 Reports the number of neurons in this layer. More...
 
double getOutput (int _neuronIndex)
 Allows for accessing the activation of a specific neuron. More...
 
double getSumOutput (int _neuronIndex)
 Allows for accessing the sum output of any specific neuron. More...
 
double getWeights (int _neuronIndex, int _weightIndex)
 Allows for accessing any specific weights in the layer. More...
 
double getWeightChange ()
 Accesses the total sum of weight changes of all the neurons in this layer. More...
 
double getWeightDistance ()
 Performs squared root on the weight change. More...
 
double getGlobalError (int _neuronIndex)
 Reports the global error that is assigned to a specific neuron in this layer. More...
 
double getInitWeight (int _neuronIndex, int _weightIndex)
 Reports the initial value that was assigned to a specific weight at the initialisatin of the network. More...
 
void saveWeights ()
 Saves the temporal weight change of all weights in all neurons into files.
 
void snapWeights (string prefix, string _trial, int _subject)
 Snaps the final distribution of weights in a specific layer, this is overwritten every time the function is called.
 
void snapWeightsMatrixFormat (string prefix)
 
void printLayer ()
 Prints on the console a full tree of this layer with the values of all weights and outputs for all neurons.
 

Detailed Description

This is the class for creating layers that are contained inside the Net class.

The Layer instances in turn contain neurons.

Constructor & Destructor Documentation

◆ Layer()

Layer::Layer ( int  _nNeurons,
int  _nInputs,
int  _subject,
string  _trial 
)

Constructor for Layer: it initialises the neurons internally.

Parameters
_nNeuronsTotal number of neurons in the layer
_nInputsTotal number of inputs to that layer

Member Function Documentation

◆ getGlobalError()

double Layer::getGlobalError ( int  _neuronIndex)

Reports the global error that is assigned to a specific neuron in this layer.

Parameters
_neuronIndexthe neuron index
Returns
the value of the global error

◆ getGradient()

double Layer::getGradient ( whichGradient  _whichGradient)

Allows for accessing the error that propagates backward in the network.

Parameters
_neuronIndexThe index from which the error is requested
Returns
Returns the error of the chosen neuron

◆ getInitWeight()

double Layer::getInitWeight ( int  _neuronIndex,
int  _weightIndex 
)

Reports the initial value that was assigned to a specific weight at the initialisatin of the network.

Parameters
_neuronIndexIndex of the neuron containing the weight
_weightIndexIndex of the weight
Returns

◆ getNeuron()

Neuron* Layer::getNeuron ( int  _neuronIndex)

Allows access to a specific neuron.

Parameters
_neuronIndexThe index of the neuron to access
Returns
A pointer to that neuron

◆ getnNeurons()

int Layer::getnNeurons ( )

Reports the number of neurons in this layer.

Returns
The total number of neurons in this layer

◆ getOutput()

double Layer::getOutput ( int  _neuronIndex)

Allows for accessing the activation of a specific neuron.

Parameters
_neuronIndexThe index of the neuron
Returns
the activation of that neuron

◆ getSumOutput()

double Layer::getSumOutput ( int  _neuronIndex)

Allows for accessing the sum output of any specific neuron.

Parameters
_neuronIndexThe index of the neuron to access
Returns
Returns the wighted sum of the inputs to that neuron

◆ getWeightChange()

double Layer::getWeightChange ( )

Accesses the total sum of weight changes of all the neurons in this layer.

Returns
sum of weight changes all neurons

◆ getWeightDistance()

double Layer::getWeightDistance ( )

Performs squared root on the weight change.

Returns
The sqr of the weight changes

◆ getWeights()

double Layer::getWeights ( int  _neuronIndex,
int  _weightIndex 
)

Allows for accessing any specific weights in the layer.

Parameters
_neuronIndexThe index of the neuron containing that weight
_weightIndexThe index of the input to which that weight is assigned
Returns
Returns the chosen weight

◆ initLayer()

void Layer::initLayer ( int  _layerIndex,
Neuron::weightInitMethod  _wim,
Neuron::biasInitMethod  _bim,
Neuron::actMethod  _am 
)

Initialises each layer with specific methods for weight/bias initialisation and activation function of neurons.

Parameters
_layerIndexThe index that is assigned to this layer by the Net class
_wimweights initialisation method, see Neuron::weightInitMethod for different options
_bimbiases initialisation method, see Neuron::biasInitMethod for different options
_amactivation method, see Neuron::actMethod for different options

◆ propInputs()

void Layer::propInputs ( int  _index,
double  _value 
)

Sets the inputs to all neurons in the deeper layers (excluding the first hidden layer)

Parameters
_indexThe index of the input
_valueThe value of the input

◆ setError()

void Layer::setError ( double  _error)

Sets the error to be propagated backward at all neurons in the output layer only.

Parameters
_leadErrorthe error to be propagated backward

◆ setInputs()

void Layer::setInputs ( const double *  _inputs,
const double  scale = 1.0,
const unsigned int  offset = 0,
const int  n = -1 
)

Sets the inputs to all neurons in the first hidden layer only.

Parameters
_inputsA pointer to an array of inputs

◆ setlearningRate()

void Layer::setlearningRate ( double  _w_learningRate,
double  _b_learningRate 
)

Sets the learning rate.

Parameters
_learningRateSets the learning rate for all neurons.

The documentation for this class was generated from the following file: