Example #1
0
        public static void Main(String[] args)
        {
            ArrayNeuralNetwork network = new ArrayNeuralNetwork(3, 6, 3);

            trainSet = countSet;

            Console.WriteLine("Press enter to start training...");
            Console.ReadLine();
            Console.WriteLine("Starting the training.");
            for (int x = 0; x < 100; x++)
            {
                logSquaredError(network, trainSet, x);

                for (int y = 0; y < 10000; y++)
                {
                    for (int z = 0; z < trainSet.Length; z++)
                    {
                        network.train(trainSet[z][0], trainSet[z][1]);
                    }
                }
            }

            Console.WriteLine("Stopped the Training.");

            for (int i = 0; i < trainSet.Length; i++)
            {
                Console.WriteLine(String.Format("Test number {0}: {1}", i, doubleArrayToString(network.process(trainSet[i][0]))));
            }

            Console.WriteLine("Press enter to start time testing of pass forward.");
            Console.ReadLine();

            for (int i = 0; i < 1000; i++)
            {
                for (int j = 0; j < 1000; j++)
                {
                    network.process(trainSet[0][0]);
                }
            }

            Console.WriteLine("Finished Testing the pass forward");
            Console.ReadLine();
        }
Example #2
0
        public static void logSquaredError(ArrayNeuralNetwork network, double[][][] testSet, int reportId)
        {
            Console.WriteLine("Performance Report ---------- " + reportId);

            double error = 0;

            for (int i = 0; i < testSet.Length; i++)
            {
                double[] results = network.process(testSet[i][0]);
                bool     success = true;
                for (int j = 0; j < results.Length; j++)
                {
                    if (Math.Abs(results[j] - testSet[i][1][j]) > 0.5)
                    {
                        success = false;
                    }
                    error += Math.Pow(results[j] - testSet[i][1][j], 2);
                }
                Console.WriteLine(String.Format("--- Test number {0} resulted in {1}", i, success));
            }

            Console.WriteLine(String.Format("The combined squared error is {0}.", error));
        }