protected void PropogateError(Step downstream, Step upstream, int upstreamNeuron, int inputNeuron)
{
int weightIndex = inputNeuron * OutputNeurons;
double upstreamState = upstream.Output[upstreamNeuron];
double inputError = 0.0;
for (int output = 0; output < OutputNeurons; output++)
{
double downstreamErrorDerivative = downstream.ErrorDerivative[output];
// Calculate inputs error gradient by taking the sum, for all outputs of
// dEk/dAj multiplied by dAj/dOj (w/sum =dEj/dOj);
inputError += (downstreamErrorDerivative * Weight[weightIndex]);
// Calculate the Weight's first derivative with respect to the error
double weightErrorGradient = downstreamErrorDerivative * upstreamState;
double deltaWeight = WeightStepSize[weightIndex] * weightErrorGradient;
Weight[weightIndex] -= deltaWeight;
weightIndex += 1;
}
upstream.ErrorDerivative[upstreamNeuron] = inputError;
}