Page 1 of 1

### Network returning wrong answers

Posted: Wed Apr 26, 2017 1:34 pm
Hello,
Currently, i have to admit I'm quite new to this area of programming so forgive me for anything i may have gotten wrong. Be it how obvious it may be.

Anyway, to dip my toes into working with networks with Aforge, I made it my goal to teach a network how to categorize odd and even numbers to help me learn the system. As easy as a task it may seem, I've tried every question given in this forum to try and get the right answer.

So currently this is the list of things I have tried and changed:
- changed to a bipolar sigmoid setup
- changed the number of neurons in all layers several times
- changed the alpha of the sigmoid functions to various combos
- changed the learning rate to various combinations
- changed the result numbers(E.G. odd = 1 and even = 0 in various combinations)
- tried changing momentum figures
- iterations of 1000, 10000

And none of it seems to make a scratch.. I'm just clueless to what I'm doing wrong all the results I receive are different wild card answers that are incorrect.

My code:
Code: Select all
`        private static void Main(string[] args)        {                        // create neural network            ActivationNetwork network = new ActivationNetwork(new                BipolarSigmoidFunction(2),                1, // two inputs in the network                5, // five neurons in the first layer                  1); // one neuron in the second layer                    // create teacher            BackPropagationLearning teacher =                new BackPropagationLearning(network);            teacher.LearningRate = 1.001;            teacher.Momentum = 1;            // loop            while(true)            {                Console.WriteLine("How many iterations should be done?");                int i = Convert.ToInt32(Console.ReadLine());                while (i != 0)                {                    // this randomizes the data sets so it's not reiterating the same data.                     Random rnd = new Random();                    double[][] input = new double[10][] {                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)},                new double[] {rnd.Next(10000)}};                    double[][] output = new double[10][] {                new double[] {sort(input[0][0])},                new double[] {sort(input[1][0])},                new double[] {sort(input[2][0])},                new double[] {sort(input[3][0])},                new double[] {sort(input[4][0])},                new double[] {sort(input[5][0])},                new double[] {sort(input[6][0])},                new double[] {sort(input[7][0])},                new double[] {sort(input[8][0])},                new double[] {sort(input[9][0])},};                    i--;                    double error = teacher.RunEpoch(input, output);                    Console.WriteLine(error);                }                Console.WriteLine("enter number");                double number = Convert.ToDouble(Console.ReadLine());                double[] test = new double[] {number}; // 0.1 = even 0.2 = odd                Console.WriteLine("Testing Networks knowledge");                Console.WriteLine(network.Compute(test)[0]);                Console.ReadKey();                network.Save("Odd-Even network.txt");                }                          }        public static double sort (double num)        {            if (num % 2 == 0)            {                return 0.1; // even            }            else            {                return 0.2; // odd            }        }        }`

Thank you in advance for your help.