private void button14_Click(object sender, EventArgs e) { if (textParas.Text.Length > 0) { ANNWrapper.LoadBPParameters(Application.StartupPath + "\\" + textParas.Text); } else { ANNWrapper.InitBPParameters(64, 8, 4); } ANNWrapper.PrintBPParameters(Application.StartupPath + "\\" + textParas.Text + "Print.txt"); }
private void btTraining_Click(object sender, EventArgs e) { m_stop = false; // btTraining.Enabled = false; if (textParas.Text.Length > 0) { ANNWrapper.LoadBPParameters(Application.StartupPath + "\\" + textParas.Text); } else { ANNWrapper.InitBPParameters(64, 8, 4); } if (textTraingInputs.Lines.Length < 1) { return; } MessageBox.Show(textTraingInputs.Lines.Length.ToString() + " Lines!"); int divideFactor = Int32.Parse(textParaFactor.Text); int count = 0; ANNWrapper.InitTrainBPLearnSpeed(Double.Parse(textSpeed.Text)); double accpt_diff = Double.Parse(textAvrgDiff.Text.ToString()); double[] inputs = new double[64]; double[] dests = new double[4]; while (true) { double this_dif = 0.0; foreach (string line in textTraingInputs.Lines) { count++; string[] strs = line.Split(','); if (strs.Length != 65) { continue; } for (int i = 0; i < 64; i++) { inputs[i] = Double.Parse(strs[i]) / divideFactor; } string dest = Convert.ToString(Int32.Parse(strs[64]), 2); if (dest.Length > 0 && dest[dest.Length - 1 - 0] == '1') { dests[0] = 1.0; } else { dests[0] = 0.0; } if (dest.Length > 1 && dest[dest.Length - 1 - 1] == '1') { dests[1] = 1.0; } else { dests[1] = 0.0; } if (dest.Length > 2 && dest[dest.Length - 1 - 2] == '1') { dests[2] = 1.0; } else { dests[2] = 0.0; } if (dest.Length > 3 && dest[dest.Length - 1 - 3] == '1') { dests[3] = 1.0; } else { dests[3] = 0.0; } double dif = ANNWrapper.Training(inputs, dests); this_dif += dif; } this_dif /= textTraingInputs.Lines.Length; if (chkAutoSave.Checked) { if (textParas.Text.Length < 1) { textParas.Text = "Training.dat"; } ANNWrapper.SaveBPParameters(Application.StartupPath + "\\" + textParas.Text); } textUnMatch.AppendText(this_dif.ToString() + "\r\n"); btTraining.Text = this_dif.ToString(); btTraining.Update(); if (this_dif <= accpt_diff || m_stop == true) { ANNWrapper.SaveBPParameters(Application.StartupPath + "\\" + textParas.Text); break; } } btTraining.Enabled = true; btTraining.Text = "Train(" + count.ToString() + ")"; }
private void button7_Click(object sender, EventArgs e) { if (textParas.Text.Length > 0) { ANNWrapper.LoadBPParameters(Application.StartupPath + "\\" + textParas.Text); } else { ANNWrapper.InitBPParameters(64, 8, 4); } DirectoryInfo Dir = new DirectoryInfo(Application.StartupPath + "\\" + textBMPFolders.Text); try { foreach (DirectoryInfo d in Dir.GetDirectories()) { if (d.ToString() == "BMP0") { EncodeBMPs(d, 0); } else if (d.ToString() == "BMP1") { EncodeBMPs(d, 1); } else if (d.ToString() == "BMP2") { EncodeBMPs(d, 2); } else if (d.ToString() == "BMP3") { EncodeBMPs(d, 3); } else if (d.ToString() == "BMP4") { EncodeBMPs(d, 4); } else if (d.ToString() == "BMP5") { EncodeBMPs(d, 5); } else if (d.ToString() == "BMP6") { EncodeBMPs(d, 6); } else if (d.ToString() == "BMP7") { EncodeBMPs(d, 7); } else if (d.ToString() == "BMP8") { EncodeBMPs(d, 8); } else if (d.ToString() == "BMP9") { EncodeBMPs(d, 9); } } } catch (Exception exp) { MessageBox.Show(exp.Message); } }