private void learnButtonClick(object sender, RoutedEventArgs e) { network = NetworkBuilder.GetBuilder().SetOutputLayerNeurons(5) .SetInputLayerNeurons(103).SetMaxEras(100000).SetHiddenLayerNeurons(6) .SetLearningRate(0.2f).SetMomentum(0.4f).SetMinError(0.0001).Build(); string[] files = Directory.GetFiles(Directory.GetCurrentDirectory() + "/Images"); foreach (string file in files) { if (Path.GetFileName(file).EndsWith(".bmp")) { continue; } Bitmap bmp = new Bitmap(file); IEnumerable <double> input = readBitmapPoints(bmp, 100, Path.GetFileNameWithoutExtension(file)); int outputIndex = Array.IndexOf(usedSigns, Path.GetFileNameWithoutExtension(file).Split('_')[0]); Console.WriteLine("Adding " + file + " as " + usedSigns[outputIndex]); network.AddLearningPair(input.ToList(), expectedOutputs[outputIndex]); } network.SingleEraEnded += data => { if (data.PercentOfError > 20) { network.SetLearningRate(0.18); network.SetMomentum(0.35); } else if (data.PercentOfError > 50) { network.SetLearningRate(0.15); network.SetMomentum(0.3); } else if (data.PercentOfError > 75) { network.SetLearningRate(0.1); network.SetMomentum(0.25); } if ((data.CurrentEra + 1) % 2000 == 0 || data.CurrentEra == 0 || data.PercentOfError >= 100) { Console.WriteLine( $"Era: {data.CurrentEra + 1}, Learn progress: {data.LearnProgress}, Overall Error: {data.OverallError}" + $", Percentage of error: {data.PercentOfError}"); } }; network.Learn(); }