Exemple #1
0
        public static void TestTraining(Perceptron brain)
        {
            foreach (var m in materials)
            {
                var res    = brain.Guess(m.Values.ToList());
                var target = m.Label;

                Console.WriteLine("**************************______________************************");

                Console.WriteLine($"{m.Values[0]} + {m.Values[1]} is below 100: {GuessResult(res)}");
                Console.WriteLine($"Guess was {GetResult(res, target)}!");

                Console.WriteLine($"Weights 1: {brain.Weights[0]} 2: {brain.Weights[1]}");

                Console.WriteLine($"The error is {brain.CalcError(res, target)}");

                Console.WriteLine("**************************______________************************");

                if (GetResult(res, target).Equals("CORRECT"))
                {
                    Counter++;
                }

                brain.Train(m.Values.ToList(), target);
                Console.WriteLine("Training...");
            }
            Console.WriteLine($"Percentage correct: {(double)Counter / materials.Count}");
            var input = Console.ReadKey();

            if (!input.ToString().ToLower().Equals("n"))
            {
                Counter = 0;
                TestTraining(brain);
            }
            else
            {
                Console.WriteLine("END");
            }
        }