Accord.Neuro.Learning.ParallelResilientBackpropagationLearning.ComputeError C# (CSharp) Method

ComputeError() public method

Compute network error for a given data set.
public ComputeError ( double input, double output ) : double
input double The input points.
output double The output points.
return double
        public double ComputeError(double[][] input, double[][] output)
        {
            Object lockSum = new Object();
            double sumOfSquaredErrors = 0;


            Parallel.For(0, input.Length,

                // Initialize
                () => 0.0,

                // Map
                (i, loopState, partialSum) =>
                {
                    // Compute network answer
                    double[] y = network.Compute(input[i]);

                    for (int j = 0; j < y.Length; j++)
                    {
                        double e = (y[j] - output[i][j]);
                        partialSum += e * e;
                    }

                    return partialSum;
                },

                // Reduce
                (partialSum) =>
                {
                    lock (lockSum) sumOfSquaredErrors += partialSum;
                }
            );

            return sumOfSquaredErrors / 2.0;
        }