Deep Neuronal Filter
Neuron Class Reference

This is the class for creating neurons inside the Layer class. More...

#include <Neuron.h>

Public Types

enum  biasInitMethod { B_NONE = 0, B_RANDOM = 1 }
 Options for method of initialising biases 0 for initialising all weights to zero 1 for initialising all weights to one 2 for initialising all weights to a random value between 0 and 1.
 
enum  weightInitMethod {
  W_ZEROS = 0, W_ONES = 1, W_RANDOM = 2, W_ONES_NORM = 3,
  W_RANDOM_NORM = 5
}
 Options for method of initialising weights 0 for initialising all weights to zero 1 for initialising all weights to one 2 for initialising all weights to a random value between 0 and 1.
 
enum  actMethod { Act_Sigmoid = 1, Act_Tanh = 2, Act_ReLU = 3, Act_NONE = 0 }
 Options for activation functions of the neuron 0 for using the logistic function 1 for using the hyperbolic tan function 2 for unity function (no activation)
 
enum  whichError { onBackwardError = 0, onMidError = 1, onForwardError = 2 }
 Options for choosing an error to monitor the gradient of 0 for monitoring the error that propagates backward 1 for monitoring the error that propagates from the middle and bilaterally 2 for monitoring the error that propagates forward.
 

Public Member Functions

 Neuron (int _nInputs)
 Constructor for the Neuron class: it initialises a neuron with specific number fo inputs to that neuron. More...
 
 ~Neuron ()
 Destructor De-allocated any memory.
 
void initNeuron (int _neuronIndex, int _layerIndex, weightInitMethod _wim, biasInitMethod _bim, actMethod _am)
 Initialises the neuron with the given methods for weight/bias initialisation and for activation function. More...
 
void setLearningRate (double _learningRate, double _b_learningRate)
 Sets the learning rate. More...
 
void setInput (int _index, double _value)
 Sets the inputs to this neuron that is located in the first hidden layer. More...
 
void propInputs (int _index, double _value)
 Sets the inputs to this neuron that can be located in any layer other than the first hidden layer. More...
 
int calcOutput (int _layerHasReported)
 Calculates the output of the neuron by performing a weighed sum of all inputs to this neuron and activating the sum. More...
 
void setError (double _value)
 Sets the error of the neuron in the first hidden layer that is to be propagated forward. More...
 
double getError ()
 Allows accessing the error of this neuron. More...
 
void updateWeights ()
 Performs one iteration of learning, that is: it updates all the weights assigned to each input to this neuron.
 
double doActivation (const double sum) const
 Performs the activation of the sum output of the neuron. More...
 
double doActivationPrime (const double input) const
 Performs inverse activation on any input that is passed to this function. More...
 
void setBackpropError (const double upstreamDeltaErrorSum)
 Sets the internal backprop error. More...
 
double getOutput ()
 Requests the output of this neuron. More...
 
double getSumOutput ()
 Requests the sum output of the neuron. More...
 
double getWeights (int _inputIndex)
 Requests a specific weight. More...
 
double getInitWeights (int _inputIndex)
 Requests a inital value of a specific weight. More...
 
double getWeightChange ()
 Requests for overall change of all weights contained in this neuron. More...
 
double getMaxWeight ()
 Requests for the maximum weights located in this neuron. More...
 
double getMinWeight ()
 Requests for the minimum weights located in this neuron. More...
 
double getSumWeight ()
 Requests for the total sum of weights located in this neuron. More...
 
double getWeightDistance ()
 Requests the weight distance of all weighs in this neuron. More...
 
int getnInputs ()
 Requests the total number of inputs to this neuron. More...
 
void saveWeights ()
 Saves the temporal weight change of all weights in this neuron into a file.
 
void printNeuron ()
 Prints on the console a full description of all weights, inputs and outputs for this neuron.
 
void setWeight (int _index, double _weight)
 Sets the weights of the neuron. More...
 

Detailed Description

This is the class for creating neurons inside the Layer class.

This is the building block class of the network.

Constructor & Destructor Documentation

◆ Neuron()

Neuron::Neuron ( int  _nInputs)

Constructor for the Neuron class: it initialises a neuron with specific number fo inputs to that neuron.

Parameters
_nInputs

Member Function Documentation

◆ calcOutput()

int Neuron::calcOutput ( int  _layerHasReported)

Calculates the output of the neuron by performing a weighed sum of all inputs to this neuron and activating the sum.

Parameters
_layerHasReportedboolean variable to indicate whether or not any neuron in this layer has reported exploding output
Returns
Returns a boolean to report whether or not this neuron has exploding output

◆ doActivation()

double Neuron::doActivation ( const double  sum) const
inline

Performs the activation of the sum output of the neuron.

Parameters
_sumthe weighted sum of all inputs
Returns
activation of the sum

◆ doActivationPrime()

double Neuron::doActivationPrime ( const double  input) const
inline

Performs inverse activation on any input that is passed to this function.

Parameters
_inputthe input value
Returns
the inverse activation of the input

◆ getError()

double Neuron::getError ( )

Allows accessing the error of this neuron.

Returns
the value of the error

◆ getInitWeights()

double Neuron::getInitWeights ( int  _inputIndex)

Requests a inital value of a specific weight.

Parameters
_inputIndexindex of the input to which the weight is assigned
Returns
teh inital value of the weight

◆ getMaxWeight()

double Neuron::getMaxWeight ( )
inline

Requests for the maximum weights located in this neuron.

Returns
Returns the max weight

◆ getMinWeight()

double Neuron::getMinWeight ( )
inline

Requests for the minimum weights located in this neuron.

Returns
Returns the min weight

◆ getnInputs()

int Neuron::getnInputs ( )

Requests the total number of inputs to this neuron.

Returns
total number of inputs

◆ getOutput()

double Neuron::getOutput ( )
inline

Requests the output of this neuron.

Returns
the output of the neuron after activation

◆ getSumOutput()

double Neuron::getSumOutput ( )
inline

Requests the sum output of the neuron.

Returns
returns the sum output of the neuron before activaiton

◆ getSumWeight()

double Neuron::getSumWeight ( )
inline

Requests for the total sum of weights located in this neuron.

Returns
Returns the sum of weights

◆ getWeightChange()

double Neuron::getWeightChange ( )

Requests for overall change of all weights contained in this neuron.

Returns
the overal weight change

◆ getWeightDistance()

double Neuron::getWeightDistance ( )

Requests the weight distance of all weighs in this neuron.

Returns
returns the sqr of the total weight change in this neuron

◆ getWeights()

double Neuron::getWeights ( int  _inputIndex)

Requests a specific weight.

Parameters
_inputIndexindex of the input to which the chosen weight is assigned
Returns
Returns the chosen weight

◆ initNeuron()

void Neuron::initNeuron ( int  _neuronIndex,
int  _layerIndex,
weightInitMethod  _wim,
biasInitMethod  _bim,
actMethod  _am 
)

Initialises the neuron with the given methods for weight/bias initialisation and for activation function.

It also specifies the index of the neuron and the index of the layer that contains this neuron.

Parameters
_neuronIndexThe index of this neuron
_layerIndexThe index of the layer that contains this neuron
_wimThe method of initialising the weights, refer to weightInitMethod for more information
_bimThe method of initialising the biases, refer to biasInitMethod for more information
_amThe function used for activation of neurons, refer to actMethod for more information

◆ propInputs()

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

Sets the inputs to this neuron that can be located in any layer other than the first hidden layer.

Parameters
_indexindex of the input
_valuevalue of the input

◆ setBackpropError()

void Neuron::setBackpropError ( const double  upstreamDeltaErrorSum)
inline

Sets the internal backprop error.

Parameters
_inputthe input value

◆ setError()

void Neuron::setError ( double  _value)

Sets the error of the neuron in the first hidden layer that is to be propagated forward.

Parameters
_valuevalue of the error

◆ setInput()

void Neuron::setInput ( int  _index,
double  _value 
)

Sets the inputs to this neuron that is located in the first hidden layer.

Parameters
_indexIndex of the input
_valueValue of the input

◆ setLearningRate()

void Neuron::setLearningRate ( double  _learningRate,
double  _b_learningRate 
)

Sets the learning rate.

Parameters
_learningRateSets the learning rate for this neuron.

◆ setWeight()

void Neuron::setWeight ( int  _index,
double  _weight 
)
inline

Sets the weights of the neuron.

Parameters
_indexindex of the weight
_weightvalue of the weight

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