Deep Neuronal Filter
Net Class Reference

Net is the main class used to set up a neural network used for closed-loop Deep Learning. More...

#include <Net.h>

Public Member Functions

 Net (const int _nLayers, const int *const _nNeurons, const int _nInputs, const int _subject, const string _trial)
 Constructor: The neural network that performs the learning. More...
 
 ~Net ()
 Destructor De-allocated any memory.
 
void initNetwork (Neuron::weightInitMethod _wim, Neuron::biasInitMethod _bim, Neuron::actMethod _am)
 Dictates the initialisation of the weights and biases and determines the activation function of the 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 the network in each iteration of learning, needs to be placed in an infinite loop. More...
 
void propInputs ()
 It propagates the inputs forward through the network.
 
void propErrorBackward ()
 Propagates the error backward.
 
void setError (double _leadError)
 Sets the error at the output layer to be propagated backward. More...
 
double getGradient (Layer::whichGradient _whichGradient)
 It provides a measure of how the magnitude of the error changes through the layers to alarm for vanishing or exploding gradients. More...
 
void updateWeights ()
 Requests that all layers perform one iteration of learning.
 
LayergetLayer (int _layerIndex)
 Allows Net to access each layer. More...
 
double getOutput (int _neuronIndex)
 Allows the user to access the activation output of a specific neuron in the output layer only. More...
 
double getSumOutput (int _neuronIndex)
 Allows the user to access the weighted sum output of a specific neuron in output layer only. More...
 
int getnLayers ()
 Informs on the total number of hidden layers (excluding the input layer) More...
 
int getnInputs ()
 Informs on the total number of inputs to the network. More...
 
double getWeightDistance ()
 Allows for monitoring the overall weight change of the network. More...
 
double getLayerWeightDistance (int _layerIndex)
 Allows for monitoring the weight change in a specific layer of the network. More...
 
double getWeights (int _layerIndex, int _neuronIndex, int _weightIndex)
 Grants access to a specific weight in the network. More...
 
int getnNeurons ()
 Informs on the total number of neurons in the network. More...
 
void saveWeights ()
 Saves the temporal changes of all weights in all neurons into files.
 
void snapWeights (string prefix, string _trial, int _subject)
 Snaps the final distribution of all weights in a specific layer, this is overwritten every time the function is called.
 
void snapWeightsMatrixFormat (string prefix)
 
void printNetwork ()
 Prints on the console a full tree of the network with the values of all weights and outputs for all neurons.
 

Detailed Description

Net is the main class used to set up a neural network used for closed-loop Deep Learning.

It initialises all the layers and the neurons internally.

(C) 2019,2020, Bernd Porr bernd.nosp@m.@gla.nosp@m.sgown.nosp@m.euro.nosp@m..tech (C) 2019,2020, Sama Daryanavard 20891.nosp@m.66d@.nosp@m.stude.nosp@m.nt.g.nosp@m.la.ac.nosp@m..uk

GNU GENERAL PUBLIC LICENSE

Constructor & Destructor Documentation

◆ Net()

Net::Net ( const int  _nLayers,
const int *const  _nNeurons,
const int  _nInputs,
const int  _subject,
const string  _trial 
)

Constructor: The neural network that performs the learning.

Parameters
_nLayersTotal number of hidden layers, excluding the input layer
_nNeuronsA pointer to an int array with number of neurons for all layers need to have the length of _nLayers.
_nInputsNumber of Inputs to the network

Member Function Documentation

◆ getGradient()

double Net::getGradient ( Layer::whichGradient  _whichGradient)

It provides a measure of how the magnitude of the error changes through the layers to alarm for vanishing or exploding gradients.

Parameters
_whichErrorchoose what error to monitor, for more information see Neuron::whichError
_whichGradientchoose what gradient of the chosen error to monitor, for more information see Layer::whichGradient
Returns
Returns the ratio of the chosen gradient in the last layer to the the first layer

◆ getLayer()

Layer* Net::getLayer ( int  _layerIndex)

Allows Net to access each layer.

Parameters
_layerIndexthe index of the chosen layer
Returns
A pointer to the chosen Layer

◆ getLayerWeightDistance()

double Net::getLayerWeightDistance ( int  _layerIndex)

Allows for monitoring the weight change in a specific layer of the network.

Parameters
_layerIndexThe index of the chosen layer
Returns
returns the Euclidean wight distance of neurons in the chosen layer from their initial value

◆ getnInputs()

int Net::getnInputs ( )

Informs on the total number of inputs to the network.

Returns
Total number of inputs

◆ getnLayers()

int Net::getnLayers ( )

Informs on the total number of hidden layers (excluding the input layer)

Returns
Total number of hidden layers in the network

◆ getnNeurons()

int Net::getnNeurons ( )

Informs on the total number of neurons in the network.

Returns
The total number of neurons

◆ getOutput()

double Net::getOutput ( int  _neuronIndex)

Allows the user to access the activation output of a specific neuron in the output layer only.

Parameters
_neuronIndexThe index of the chosen neuron
Returns
The value at the output of the chosen neuron

◆ getSumOutput()

double Net::getSumOutput ( int  _neuronIndex)

Allows the user to access the weighted sum output of a specific neuron in output layer only.

Parameters
_neuronIndexThe index of the chosen neuron
Returns
The value at the sum output of the chosen neuron

◆ getWeightDistance()

double Net::getWeightDistance ( )

Allows for monitoring the overall weight change of the network.

Returns
returns the Euclidean wight distance of all neurons in the network from their initial value

◆ getWeights()

double Net::getWeights ( int  _layerIndex,
int  _neuronIndex,
int  _weightIndex 
)

Grants access to a specific weight in the network.

Parameters
_layerIndexIndex of the layer that contains the chosen weight
_neuronIndexIndex of the neuron in the chosen layer that contains the chosen weight
_weightIndexIndex of the input to which the chosen weight is assigned
Returns
returns the value of the chosen weight

◆ initNetwork()

void Net::initNetwork ( Neuron::weightInitMethod  _wim,
Neuron::biasInitMethod  _bim,
Neuron::actMethod  _am 
)

Dictates the initialisation of the weights and biases and determines the activation function of the neurons.

Parameters
_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

◆ setError()

void Net::setError ( double  _leadError)

Sets the error at the output layer to be propagated backward.

Parameters
_leadErrorThe closed-loop error for learning

◆ setInputs()

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

Sets the inputs to the network in each iteration of learning, needs to be placed in an infinite loop.

Parameters
_inputsA pointer to the array of inputs

◆ setLearningRate()

void Net::setLearningRate ( double  _w_learningRate,
double  _b_learningRate 
)

Sets the learning rate.

Parameters
_learningRateSets the learning rate for all layers and neurons.

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