AForge.Neuro.Learning.BackPropagationLearning.RunEpoch C# (CSharp) Method

RunEpoch() public method

Runs learning epoch.

The method runs one learning epoch, by calling Run method for each vector provided in the input array.

public RunEpoch ( double input, double output ) : double
input double Array of input vectors.
output double Array of output vectors.
return double
        public double RunEpoch( double[][] input, double[][] output )
        {
            double error = 0.0;

            // run learning procedure for all samples
            for ( int i = 0; i < input.Length; i++ )
            {
                error += Run( input[i], output[i] );
            }

            // return summary error
            return error;
        }

Usage Example

Example #1
0
 public void test() {
     // initialize input and output values
     var input = new double[4][] {
         new double[] { 0, 0 }, new double[] { 0, 1 },
         new double[] { 1, 0 }, new double[] { 1, 1 }
     };
     var output = new double[4][] {
         new double[] { 0 }, new double[] { 1 },
         new double[] { 1 }, new double[] { 1 }
     };
     // create neural network
     var network = new ActivationNetwork(
             new SigmoidFunction(2),
             2, // two inputs in the network
             //2, // two neurons in the first layer
             1); // one neuron in the second layer
     // create teacher
     var teacher =
             new BackPropagationLearning(network);
     // loop
     while (true) {
         // run epoch of learning procedure
         var error = teacher.RunEpoch(input, output);
         // check error value to see if we need to stop
         // ...
         if (error < 0.001) {
             break;
         }
     }
     Console.WriteLine(network.Compute(new double[] { 0, 0 })[0] + ","
                       + network.Compute(new double[] { 0, 1 })[0] + ","
                       + network.Compute(new double[] { 1, 0 })[0] + ","
                       + network.Compute(new double[] { 1, 1 })[0]);
 }
All Usage Examples Of AForge.Neuro.Learning.BackPropagationLearning::RunEpoch