magician-david / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

Problem with output of a Back Propagation Learning NN #225

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have this code and I expect the result to be 2, but I get 0.9999 ~ 1. Am I 
doing something wrong? The network is not trained enough?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Accord.Statistics.Analysis;
using AForge.Neuro;
using AForge.Neuro.Learning;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            // initialize input and output values
            double[][] input = new double[4][] {

    new double[] {3, 3}, 
    new double[] {5, 6},
    new double[] {7, 9}, 
    new double[] {13, 2}
};
            double[][] output = new double[4][] {
    new double[] {1}, 
    new double[] {1},
    new double[] {2}, 
    new double[] {2}
};
            // create neural network
            ActivationNetwork 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
            BackPropagationLearning teacher = new BackPropagationLearning(network);
            // loop
            bool needToStop = false;

            while (!needToStop)
            {
                // run epoch of learning procedure
                double error = teacher.RunEpoch(input, output);
                Console.WriteLine(error);

                if (error < 1.0001)
                    needToStop = true;
                // check error value to see if we need to stop
                // ...
            }

            double[] result = network.Compute(new double[] { 13, 2 });
            Console.WriteLine(result[0]);
        }
}

Original issue reported on code.google.com by Tonch...@gmail.com on 19 Jun 2011 at 5:40

GoogleCodeExporter commented 8 years ago
>> Am I doing something wrong?
You just don't understand the concept of ANN. The sigmoid function provides 
output values in [0, 1] range. It will never provide anything out of that 
range, like 2. And it will never learn in your case.

Read some info about ANN.

P.S. If you have a question, you are welcome to go to forum. Issue tracking 
system is for bug reports, enhancement requests or contribution.

Original comment by andrew.k...@gmail.com on 19 Jun 2011 at 7:58