private void autoOptimize(object sender, EventArgs e) { var hidden = 3; var minError = Double.MaxValue; Parallel.ForEach(new double[] { 0.01, 0.05, 0.1, 0.3, 0.5, 0.7, 0.9, 0.95, 0.96, 0.97, 0.98, 0.99, 1 }, alpha => { foreach (var eta in new double[] { 0.01, 0.05, 0.1, 0.3, 0.5, 0.7, 0.9, 0.95, 0.96, 0.97, 0.98, 0.99, 1 }) { for (int j = 0; j < 10; j++) { var nn = new MLP.MLP(patterns, targets, hidden, alpha, eta); var error = 0.0; for (int i = 0; i < 10000; i++) error = nn.train(); if (error < minError) { Console.WriteLine("Alpha =" + alpha + " eta=" + eta + " error=" + error); minError = error; } } } }); Console.WriteLine("Done"); }
public SimpleTestDemo() { InitializeComponent(); var patterns = new double[1, 1]; var targets = new double[1, 1]; patterns[0, 0] = 0; targets[0, 0] = 0; var nn = new MLP.MLP(Matrix<Double>.Build.DenseOfArray(patterns), Matrix<Double>.Build.DenseOfArray(targets), 1, 0, 1.0); for (int i = 0; i < 2; i++) { nn.train(); } Console.Write(""); }
private void runButton_Click(object sender, EventArgs e) { prepareChart(); var patterns = DenseMatrix.OfArray(new double[,] { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 }, { 1, 0 }, { 1, 1 } }).Transpose(); var targets = DenseMatrix.OfArray(new double[,] { { 0, 1, 1, 0, 1, 0 } }); var cycles = (int)cyclesNumeric.Value; var nn = new MLP.MLP(patterns, targets, (int)hiddenNumeric.Value, (double)alphaNumeric.Value, (double)etaNumeric.Value); for (int i = 0; i < cycles; i++) { var error = nn.train(); var result = nn.evaluate(patterns); for (int j = 0; j < 4; j++) chart1.Series[j].Points.AddY(result[0, j]); chart2.Series.Last().Points.AddY(error); } }
private void runButton_Click(object sender, EventArgs e) { int cycles = prepareCharts(); var nn = new MLP.MLP(patterns, targets, (int)hiddenNumeric.Value, (double)alphaNumeric.Value, (double)etaNumeric.Value); for (int i = 0; i < cycles; i++) chart2.Series.Last().Points.AddY(nn.train()); var result = nn.evaluate(patterns); setLabelText(result); }