static void Main(string[] args) { Learning.TrainingExample[] exs_pics = new Learning.TrainingExample[100]; for (int i = 1; i <= 50; i++) { exs_pics[i - 1] = new Learning.TrainingExample(readImage(new Bitmap($"{string.Format("o{00:00}.bmp", i)}")).Select(b => (double)b).ToArray(), new double[] { 0, 1 }); } for (int i = 1; i <= 50; i++) { exs_pics[i + 49] = new Learning.TrainingExample(readImage(new Bitmap($"{string.Format("x{00:00}.bmp", i)}")).Select(b => (double)b).ToArray(), new double[] { 1, 0 }); } uint[] config = new uint[] { 16 * 16, 30, 4, 2 }; //double[] solution = Learning.TrainNeuralNetworkRuleofTwo(exs_pics, config, Genetics.Hash, 1); double[] solution = Learning.TrainNeuralNetworkSelectiveBreeding(exs_pics, config, Genetics.Hash, 50); //double[] solution = Learning.TrainNeuralNetworkRoulette(exs_pics, config, Genetics.Hash, 1); double[][][] wsss = Neural.FoldExpression(solution, config); double[] cross = Neural.Network(Neural.Sigmoid, wsss, readImage(new Bitmap("test01o.bmp")).Select(b => (double)b)).ToArray(); double[] circle = Neural.Network(Neural.Sigmoid, wsss, readImage(new Bitmap("test11x.bmp")).Select(b => (double)b)).ToArray(); int nCorrects = 0; for (int i = 1; i <= 10; i++) { double[] outs = Neural.Network(Neural.Sigmoid, wsss, readImage(new Bitmap(string.Format("test{00:00}o.bmp", i))).Select(b => (double)b)).ToArray(); Console.WriteLine($"TESTING CROSS\n\tProbability of cross: {outs[0]}, Probability of circle: {outs[1]}"); if (outs[0] < outs[1]) { nCorrects++; } } for (int i = 11; i <= 20; i++) { double[] outs = Neural.Network(Neural.Sigmoid, wsss, readImage(new Bitmap(string.Format("test{00:00}x.bmp", i))).Select(b => (double)b)).ToArray(); Console.WriteLine($"TESTING CIRCLE\n\tProbability of cross: {outs[0]}, Probability of circle: {outs[1]}"); if (outs[0] > outs[1]) { nCorrects++; } } Console.WriteLine($"nCorrects={nCorrects}"); }