public TLUControl() { InitializeComponent(); XYgraph = new XYGraph(XY_Panel.Width, XY_Panel.Height, 10); tlu = new TLUmodel(1.5, 1, new Data(80, -100), 5000, this); error.Hide(); XY_Line_Panel.Hide(); }
private void TrainBtn_Click(object sender, EventArgs e) { if (locked) { return; } locked = true; ResetBtn.ButtonText = "Stop"; error.Hide(); double a, t, w1, w2; int m; try { a = Convert.ToDouble(Tb1.Text); t = Convert.ToDouble(Tb2.Text); w1 = Convert.ToDouble(Tb3.Text); w2 = Convert.ToDouble(Tb4.Text); m = Convert.ToInt16(Tb5.Text); } catch { ErrorAnimator.ShowSync(error); return; } error.Hide(); ShowLog("Create TLU model with\n"); ShowLog("Max traing round:" + m); ShowLog("\nLearning Rate:" + a); ShowLog("\nThreshold:" + t); ShowLog("\nw1:" + w1); ShowLog("\nw2:" + w2); ShowLog("\nTraining Data:\n"); tlu = new TLUmodel(t, a, new Data(w1, w2), m, this); for (int i = 0; i < XYgraph.Map.Length; i++) { if (XYgraph.Map[i] != -1) { Point p = XYgraph.ConvertToXY(i); Console.WriteLine(p.X + " " + p.Y + " v=" + XYgraph.Map[i]); Data tmp = new Data(p.X * 0.5, p.Y * 0.5, XYgraph.Map[i]); tlu.q.Enqueue(tmp); ShowLog("( " + (p.X * 0.5) + " , " + (p.Y * 0.5) + " ) value=" + XYgraph.Map[i] + "\n"); } } if (tlu.q.Count > 0) { tlu.Train(); } else { ReleaseBtn(); } }