Hidden neuron gradients complete
This commit is contained in:
parent
370451c2e6
commit
26a51ce476
11
Neuron.cpp
11
Neuron.cpp
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Neuron.h"
|
#include "Neuron.h"
|
||||||
|
#include "Layer.h"
|
||||||
|
|
||||||
Neuron::Neuron(double value)
|
Neuron::Neuron(double value)
|
||||||
: outputValue(value)
|
: outputValue(value)
|
||||||
@ -64,7 +65,10 @@ double Neuron::sumDOW(const Layer & nextLayer) const
|
|||||||
{
|
{
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
|
||||||
// sum it up
|
for (size_t i = 0; i < nextLayer.size() - 1; ++i)
|
||||||
|
{
|
||||||
|
sum += outputWeights[i] * nextLayer[i].getGradient();
|
||||||
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@ -75,3 +79,8 @@ void Neuron::calcHiddenGradients(const Layer &nextLayer)
|
|||||||
gradient = dow * transferFunctionDerivative(outputValue);
|
gradient = dow * transferFunctionDerivative(outputValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Neuron::getGradient() const
|
||||||
|
{
|
||||||
|
return gradient;
|
||||||
|
}
|
||||||
|
|
||||||
|
2
Neuron.h
2
Neuron.h
@ -23,6 +23,8 @@ public:
|
|||||||
void calcOutputGradients(double targetValue);
|
void calcOutputGradients(double targetValue);
|
||||||
void calcHiddenGradients(const Layer &nextLayer);
|
void calcHiddenGradients(const Layer &nextLayer);
|
||||||
|
|
||||||
|
double getGradient() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static double transferFunction(double inputValue);
|
static double transferFunction(double inputValue);
|
||||||
static double transferFunctionDerivative(double inputValue);
|
static double transferFunctionDerivative(double inputValue);
|
||||||
|
Reference in New Issue
Block a user