private void button2_Click(object sender, EventArgs e) { this.Enabled = false; // Тут просто тестирование новой выборки // Создаём новую обучающую выборку SamplesSet samples = new SamplesSet(); for (int i = 0; i < (int)TrainingSizeCounter.Value; i++) { samples.AddSample(generator.GenerateFigure()); } double accuracy = net.TestOnDataSet(samples); StatusLabel.Text = string.Format("Точность на тестовой выборке : {0,5:F2}%", accuracy * 100); if (accuracy * 100 >= AccuracyCounter.Value) { StatusLabel.ForeColor = Color.Green; } else { StatusLabel.ForeColor = Color.Red; } this.Enabled = true; }
private async Task <double> train_networkAsync(int training_size, int epoches, double acceptable_error, bool parallel = true) { // Выключаем всё ненужное label1.Text = "Выполняется обучение..."; label1.ForeColor = Color.Red; groupBox1.Enabled = false; pictureBox1.Enabled = false; trainOneButton.Enabled = false; // Создаём новую обучающую выборку SamplesSet samples = new SamplesSet(); for (int i = 0; i < training_size; i++) { samples.AddSample(generator.GenerateFigure()); } // Обучение запускаем асинхронно, чтобы не блокировать форму double f = await Task.Run(() => net.TrainOnDataSet(samples, epoches, acceptable_error, parallel)); label1.Text = "Щелкните на картинку для теста нового образа"; label1.ForeColor = Color.Green; groupBox1.Enabled = true; pictureBox1.Enabled = true; trainOneButton.Enabled = true; StatusLabel.Text = "Accuracy: " + f.ToString(); StatusLabel.ForeColor = Color.Green; return(f); }
public SamplesSet ConvertSet(string path) { SamplesSet set = new SamplesSet(); for (int i = 0; i < 300; i++) { for (int j = 0; j < 3000; j += 300) { if (i == 0 && j == 0) { continue; } Bitmap cur_img = new Bitmap(path + (i + j).ToString() + ".jpg"); set.AddSample(Convert(cur_img, (FigureType)(j / 300))); } } return(set); }