AdvancedOCR.FeedForwardWeights.PropogateError C# (CSharp) Method

PropogateError() protected method

protected PropogateError ( Step downstream, Step upstream, int upstreamNeuron, int inputNeuron ) : void
downstream Step
upstream Step
upstreamNeuron int
inputNeuron int
return void
        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;
        }