示例#1
0
 private void EvaluateOutputGradients(Layer pLayer, double[] pResults, double[] gradient)
 {
     // Start at 1 because 0 is the bias and thus no error on this one.
     for (int i = 1; i < pLayer.Size; ++i)
     {
         gradient[i] = 2 * (pLayer.Outputs[i] - pResults[i - 1]) * pLayer.GetActivationDerivativeFor(i);
     }
 }
示例#2
0
        private void EvaluateHiddenGradients(Layer pLayer, Layer pPreviousLayer, double[] pResults, double[] gradient, double[] previousGradient)
        {
            for (int i = 0; i < pLayer.Size; ++i)
            {
                double sum = 0;

                // sum
                for (int k = 1; k < pPreviousLayer.Size; ++k)
                    sum += pPreviousLayer.GetWeightsFor(k)[i] * previousGradient[k];

                gradient[i] = pLayer.GetActivationDerivativeFor(i) * sum;
            }
        }