Feedforward Closedloop Learning
|
Layer which contains the neurons of one layer. More...
#include <layer.h>
Public Types | |
enum | WeightNormalisation { WEIGHT_NORM_NONE = 0, WEIGHT_NORM_LAYER_EUCLEDIAN = 1, WEIGHT_NORM_NEURON_EUCLEDIAN = 2, WEIGHT_NORM_LAYER_MANHATTAN = 3, WEIGHT_NORM_NEURON_MANHATTAN = 4, WEIGHT_NORM_LAYER_INFINITY = 5, WEIGHT_NORM_NEURON_INFINITY = 6 } |
Weight normalisation constants Defines if weights are normalised layer-wide or for every neuron separately. | |
Public Member Functions | |
Layer (int _nNeurons, int _nInputs) | |
Constructor. More... | |
~Layer () | |
Destructor Frees all memory. More... | |
void | calcOutputs () |
Calculates the output values in all neurons. More... | |
void | doLearning () |
Adjusts the weights. More... | |
void | setError (double _error) |
Sets the global error for all neurons. More... | |
void | setError (int i, double _error) |
sets the error individually More... | |
void | setErrors (double *_errors) |
Sets all errors from an input array. More... | |
double | getError (int i) |
Retrieves the error. More... | |
void | setBias (double _bias) |
Sets the global bias for all neurons. More... | |
void | setInput (int inputIndex, double input) |
Set the input value of one input. More... | |
void | setInputs (double *_inputs) |
Sets all inputs from an input array. More... | |
void | setLearningRate (double _learningRate) |
Sets the learning rate of all neurons. More... | |
void | setActivationFunction (Neuron::ActivationFunction _activationFunction) |
Set the activation function. More... | |
void | setMomentum (double _momentum) |
Set the momentum of all neurons in this layer. More... | |
void | setDecay (double _decay) |
Sets the weight decay scaled by the learning rate. More... | |
void | initWeights (double _max=1, int initBiasWeight=1, Neuron::WeightInitMethod weightInitMethod=Neuron::MAX_OUTPUT_RANDOM) |
Inits the weights. More... | |
double | getOutput (int index) |
Gets the outpuut of one neuron. More... | |
Neuron * | getNeuron (int index) |
Gets a pointer to one neuron. More... | |
int | getNneurons () |
Gets the number of neurons. More... | |
int | getNinputs () |
Number of inputs. More... | |
void | setConvolution (int width, int height) |
Defines a 2D geometry for the input layer of widthxheight. More... | |
void | setMaxDetLayer (int _m) |
Maxium detection layer. More... | |
void | setNormaliseWeights (WeightNormalisation _normaliseWeights) |
Normalise the weights. More... | |
void | setDebugInfo (int layerIndex) |
Sets the layer index within the whole network. More... | |
void | setStep (long int step) |
Sets the simulation step in the layer for debug purposes. More... | |
double | getWeightDistanceFromInitialWeights () |
Get weight distance from the start of the simulation. More... | |
void | doNormaliseWeights () |
Performs the weight normalisation. More... | |
void | setUseThreads (int _useThreads) |
Sets if threads should be used. More... | |
int | saveWeightMatrix (char *filename) |
Save weight matrix for documentation and debugging. More... | |
Layer which contains the neurons of one layer.
It performs all computations possible in a layer. In particular it calls all neurons in separate threads and triggers the compuations there. These functions are all called from the parent class.
Layer::Layer | ( | int | _nNeurons, |
int | _nInputs | ||
) |
Constructor.
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007.
_nNeurons | Number of neurons in the layer. |
_nInputs | Number of inputs to the Layer. |
_nFilters | Number of lowpass filters at each input. |
_minT | Minimum time of the lowpass filter. |
_maxT | Maximum time of the lowpass filter. |
(C) 2017, Bernd Porr bernd (C) 2017, Paul Miller @gla sgown euro .techpaul@ glas gowne uro. tech
Layer::~Layer | ( | ) |
Destructor Frees all memory.
void Layer::calcOutputs | ( | ) |
Calculates the output values in all neurons.
void Layer::doLearning | ( | ) |
Adjusts the weights.
void Layer::doNormaliseWeights | ( | ) |
Performs the weight normalisation.
double Layer::getError | ( | int | i | ) |
Retrieves the error.
i | Index of the neuron |
|
inline |
Gets a pointer to one neuron.
index | The index number of the neuron. |
|
inline |
Number of inputs.
|
inline |
Gets the number of neurons.
|
inline |
Gets the outpuut of one neuron.
index | The index number of the neuron. |
double Layer::getWeightDistanceFromInitialWeights | ( | ) |
Get weight distance from the start of the simulation.
void Layer::initWeights | ( | double | _max = 1 , |
int | initBiasWeight = 1 , |
||
Neuron::WeightInitMethod | weightInitMethod = Neuron::MAX_OUTPUT_RANDOM |
||
) |
Inits the weights.
_max | Maximum value if using random init. |
initBiasWeight | if one also the bias weight is initialised. |
weightInitMethod | The methid employed to init the weights. |
int Layer::saveWeightMatrix | ( | char * | filename | ) |
Save weight matrix for documentation and debugging.
filename | The filename it should be saved to. |
void Layer::setActivationFunction | ( | Neuron::ActivationFunction | _activationFunction | ) |
Set the activation function.
_activationFunction | The activation function. See: Neuron::ActivationFunction |
void Layer::setBias | ( | double | _bias | ) |
Sets the global bias for all neurons.
_bias | The bias for all neurons |
void Layer::setConvolution | ( | int | width, |
int | height | ||
) |
Defines a 2D geometry for the input layer of widthxheight.
width | The width of the convolutional window. |
height | The height of the convolution window. |
void Layer::setDebugInfo | ( | int | layerIndex | ) |
Sets the layer index within the whole network.
layerIndex | The layer index in the whole network. |
void Layer::setDecay | ( | double | _decay | ) |
Sets the weight decay scaled by the learning rate.
_decay | The decay rate of the weights |
void Layer::setError | ( | double | _error | ) |
Sets the global error for all neurons.
_error | Sets the error in the whole layer |
void Layer::setError | ( | int | i, |
double | _error | ||
) |
sets the error individually
i | Index of the neuron |
_error | The error to be set |
void Layer::setErrors | ( | double * | _errors | ) |
Sets all errors from an input array.
_errors | is an array of errors |
void Layer::setInput | ( | int | inputIndex, |
double | input | ||
) |
Set the input value of one input.
inputIndex | The index number of the input. |
input | The value of the input |
void Layer::setInputs | ( | double * | _inputs | ) |
Sets all inputs from an input array.
_inputs | array of all inputs |
void Layer::setLearningRate | ( | double | _learningRate | ) |
Sets the learning rate of all neurons.
_learningRate | The learning rate |
|
inline |
Maxium detection layer.
Experimental. This hasn't been implemented.
void Layer::setMomentum | ( | double | _momentum | ) |
Set the momentum of all neurons in this layer.
_momentum | The momentum for all neurons in this layer. |
void Layer::setNormaliseWeights | ( | WeightNormalisation | _normaliseWeights | ) |
Normalise the weights.
_normaliseWeights | Metod of normalisation. |
void Layer::setStep | ( | long int | step | ) |
Sets the simulation step in the layer for debug purposes.
step | Step number. |
|
inline |
Sets if threads should be used.
_useThreads | 0 = no Threads, 1 = Threads |