Feedforward Closedloop Learning
|
71 enum WeightInitMethod { MAX_OUTPUT_RANDOM = 0, MAX_WEIGHT_RANDOM = 1, MAX_OUTPUT_CONST = 2, CONST_WEIGHTS = 3};
92 activationFunction = _activationFunction;
130 assert((_index>=0)&&(_index<nInputs));
131 return mask[_index] ? weights[_index] : 0;
139 assert((_index>=0)&&(_index<nInputs));
140 weights[_index]=_weight;
159 assert((_index>=0)&&(_index<nInputs));
160 inputs[_index] = _value;
168 assert((_index>=0)&&(_index<nInputs));
169 return inputs[_index];
185 inline void setBias(
double _bias) { bias=_bias; };
196 inline void setMomentum(
double _momentum) { momentum = _momentum; };
226 assert((_width*_height)==nInputs);
237 void setMask(
int x,
int y,
unsigned char c);
242 void setMask(
unsigned char c);
249 unsigned char getMask(
int x,
int y);
255 unsigned char getMask(
int index) {
return mask[index]; };
299 layerIndex = _layerIndex;
300 neuronIndex = _neuronIndex;
312 unsigned char* mask = 0;
314 double* initialWeights = 0;
315 double* weightChange = 0;
317 double biasweight = 0;
318 double biasweightChange = 0;
324 double learningRate = 0;
325 double learningRateFactor = 1;
double dActivation()
Returns the output of the neuron fed through the derivative of the activation.
Definition: neuron.cpp:114
double getWeight(int _index)
Gets one weight.
Definition: neuron.h:129
unsigned char getMask(int index)
Boundary safe return of the mask in flat form.
Definition: neuron.h:255
unsigned char getMask(int x, int y)
Boundary safe return of the mask in (x,y) coordinates.
Definition: neuron.cpp:413
int getNinputs()
Get the number of inputs to the neuron.
Definition: neuron.h:215
void setActivationFunction(ActivationFunction _activationFunction)
Sets the activation function.
Definition: neuron.h:91
double getManhattanNormOfWeightVector()
Calculates the Manhattan length of the weight vector /return Manhattan length of the weight vector.
Definition: neuron.cpp:201
void setMask(int x, int y, unsigned char c)
Boundary safe manipulation of the convolution mask.
Definition: neuron.cpp:399
~Neuron()
Destructor Tidies up any memory allocations.
Definition: neuron.cpp:38
void saveInitialWeights()
Save the initial weights.
Definition: neuron.cpp:344
double getMaxWeightValue()
Maximum weight value.
Definition: neuron.cpp:352
void setDecay(double _decay)
Sets the weight decay over time.
Definition: neuron.h:201
double getSum()
Gets the weighted sum of all inputs pre-activation function.
Definition: neuron.h:123
void setMomentum(double _momentum)
Sets the momentum.
Definition: neuron.h:196
static void * doMaxDetThread(void *object)
Wrapper for thread callback for maxdet.
Definition: neuron.h:64
double getBiasWeight()
Gets the bias weight.
Definition: neuron.h:175
void setStep(long int _step)
Sets the simulation step for debugging and logging.
Definition: neuron.h:306
void normaliseWeights(double norm)
Normalises the weights with a divisor.
Definition: neuron.cpp:256
double getInput(int _index)
Get the value at one input.
Definition: neuron.h:167
double getDecay()
Gets the weight decay over time.
Definition: neuron.h:208
void setDebugInfo(int _layerIndex, int _neuronIndex)
Sets debug info populated from Layer.
Definition: neuron.h:298
WeightInitMethod
Constants how to init the weights in the neuron.
Definition: neuron.h:71
void initWeights(double _max=1, int initBias=1, WeightInitMethod _wm=MAX_OUTPUT_RANDOM)
Inits the weights in the neuron.
Definition: neuron.cpp:298
void setGeometry(int _width, int _height)
Tells the layer that it's been a 2D array originally to be a convolutional layer.
Definition: neuron.h:225
void setError(double _error)
Sets the error in the neuron If the derivative is activated then the derivative of the error is calcu...
Definition: neuron.cpp:393
double getSumOfSquaredWeightVector()
Calculates the sum of the squared weight vector values.
Definition: neuron.cpp:183
double getWeightDistanceFromInitialWeights()
Weight development.
Definition: neuron.cpp:380
double getOutput()
Gets the output of the neuron.
Definition: neuron.h:118
void setInput(int _index, double _value)
Sets one input.
Definition: neuron.h:158
void doLearning()
Performs the learning Performs ICO learning in the neuron: pre * error.
Definition: neuron.cpp:150
Neuron(int _nInputs)
Constructor.
Definition: neuron.cpp:17
double getEuclideanNormOfWeightVector()
Calculates the Eucledian length of the weight vector.
Definition: neuron.h:265
void doMaxDet()
Detects max of an input Switches the highest weight to 1 and the others to 0.
Definition: neuron.cpp:274
double getAverageOfWeightVector()
Calculates the average of the weight values.
Definition: neuron.cpp:236
Neuron which calculates the output and performs learning.
Definition: neuron.h:19
void setWeight(int _index, double _weight)
Sets one weight.
Definition: neuron.h:138
double getInfinityNormOfWeightVector()
Calculates the Infinity norm of the vector.
Definition: neuron.cpp:218
void calcOutput()
Calculate the output of the neuron This runs the filters, activation functions, sum it all up.
Definition: neuron.cpp:47
void setBias(double _bias)
Sets the bias input value.
Definition: neuron.h:185
double getMinWeightValue()
Minimum weight value.
Definition: neuron.cpp:366
void setLearningRate(double _learningrate)
Sets the learning rate.
Definition: neuron.h:190
ActivationFunction
Activation functions on offer LINEAR: linear unit, TANH: tangens hyperbolicus, RELU: linear rectifier...
Definition: neuron.h:86
double getError()
Gets the error as set by setError.
Definition: neuron.h:152
void setBiasWeight(double _biasweight)
Sets the bias weight.
Definition: neuron.h:180
static void * calcOutputThread(void *object)
Wrapper for thread callback for output calc.
Definition: neuron.h:40
static void * doLearningThread(void *object)
Wrapper for thread callback for learning.
Definition: neuron.h:52