private void bControllerReset_Click(object sender, EventArgs e) { int inputCount; int outputCount; var structure = ParseStructureBox(out inputCount, out outputCount); Tuple <double, double, double, double> Norm = Tuple.Create(10.0, 0.0, 3.0, 0.0); List <double[]> input = new List <double[]>(); List <double[]> output = new List <double[]>(); var t = Data.ReadData(FilePath, inputCount, outputCount, Norm, rbMNIST.Checked); input = t.Item1; output = t.Item2; PerceptronNetwork network = new MLP.PerceptronNetwork(structure); NetworkController = new MLP.Network_Control(network, output, input, Double.Parse(tbLearningRate.Text), false, Norm, inputCount, outputCount); cartesianChart1.Series[0].Values.Clear(); cartesianChart2.Series[0].Values.Clear(); cartesianChart3.Series[0].Values.Clear(); if (!cbdisabledrawing.Checked) { var Image = NetworkImage.Draw(NetworkController.Network, NetworkController.Network.Layers.Count); IMG_NetworkTopography.Image = Image; } }
public Form1() { FilePath = "IRIS_Train.csv"; Tuple <double, double, double, double> Norm = Tuple.Create(10.0, 0.0, 3.0, 0.0); List <double[]> input = new List <double[]>(); List <double[]> output = new List <double[]>(); var t = Data.ReadData("IRIS.csv", 4, 1, Norm, false); input = t.Item1; output = t.Item2; PerceptronNetwork network = new MLP.PerceptronNetwork(new int[] { 4, 5, 5, 1 }); NetworkController = new MLP.Network_Control(network, output, input, 0.02, false, Norm, 4, 1); InitializeComponent(); //Set image to the starting network's image if (!cbdisabledrawing.Checked) { var Image = NetworkImage.Draw(network, network.Layers.Count); IMG_NetworkTopography.Image = Image; IMG_NetworkTopography.SizeMode = PictureBoxSizeMode.Zoom; } rtbConsole.Text = ""; NetworkController.Paused = true; }
private void rbMNIST_CheckedChanged(object sender, EventArgs e) { //btnbatch.Enabled = false; Tuple <double, double, double, double> Norm = Tuple.Create(255.0, 0.0, 9.0, 0.0); List <double[]> input = new List <double[]>(); List <double[]> output = new List <double[]>(); var t = Data.ReadData("mnist_test.csv", 785, 1, Norm, true); input = t.Item1; output = t.Item2; //https://www.kaggle.com/donfuzius/vectordigits PerceptronNetwork network = new MLP.PerceptronNetwork(new int[] { 784, 784, 1 }); NetworkController = new MLP.Network_Control(network, output, input, double.Parse(tbLearningRate.Text), false, Norm, 784, 1); tbStructure.Text = "784 784 1"; /* * Tuple<double, double, double, double> Norm = Tuple.Create(255.0, 0.0, 9.0, 0.0); * List<double[]> input = new List<double[]>(); * List<double[]> output = new List<double[]>(); * var t = Data.ReadData(path, 784, 1, Norm); * input = t.Item1; * output = t.Item2; * * int errors = 0; * for (int i = 0; i < input.Count; i++) * { * for (int j = 0; j < output[i].Length; j++) * { * var expected = Data.inverseNormalize(output[i][j], Norm.Item4, Norm.Item3); * * var a = NetworkController.Network.Activate(input[i]); //Get the result from the given outputs * var bbb = Data.inverseNormalize(a[j], Norm.Item4, Norm.Item3); //Inverse normalize the result to fit it between output values * * if (Math.Round(bbb) != expected) { errors++; }//Error? * rtbConsole.Text += "Expected: " + expected + " Got :" + Math.Round(bbb) + "\n"; * rtbConsole.SelectionStart = rtbConsole.Text.Length; * rtbConsole.ScrollToCaret(); * * } * * * } * rtbConsole.Text += "Total Number of Errors: " + errors + "/" + input.Count*output.Count + "\n"; * */ }
/// <summary> /// Draws selection boundry of the two given features, decrepit /// </summary> /// <param name="p"></param> /// <param name="feature1"></param> /// <param name="feature2"></param> /// <param name="otherInputsStatic"></param> /// <param name="possibleOutputCount"></param> /// <param name="minOutputValue"></param> /// <param name="maxOutputValue"></param> public static void DrawBoundryMap_IRIS(Network_Control p, double[] feature1, double[] feature2, double[] otherInputsStatic, int possibleOutputCount, double minOutputValue, double maxOutputValue) { int sizeMod = 20; int width = feature1.Length * sizeMod; int height = feature2.Length * sizeMod; Bitmap m = new Bitmap(width, height); Graphics g = Graphics.FromImage(m); Random rnd = new Random(); /*var a = NetworkController.Network.Activate(input[i]); * var bbb = Data.inverseNormalize(a[0], 0.0, 3.0);*/ List <int[]> GradientColors = new List <int[]>(); for (int i = 0; i < possibleOutputCount; i++) { GradientColors.Add(new int[] { rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255) }); } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { var sx = (int)Math.Floor((double)(y / sizeMod)); var sy = (int)Math.Floor((double)(x / sizeMod)); var a = p.Network.Activate(new double[] { feature1[sx], feature2[sy] }.Concat(otherInputsStatic).ToArray()); var bbb = Data.inverseNormalize(a[0], minOutputValue, maxOutputValue); for (int k = 0; k < GradientColors.Count; k++) { if (Math.Round(bbb) == k) { //var c = Color.FromArgb((int)Math.Abs(Math.Floor(GradientColors[k][0] * multiplier)), Math.Abs((int)Math.Floor(GradientColors[k][1] * multiplier)), Math.Abs((int)Math.Floor(GradientColors[k][2] * multiplier))); Pen pen = new Pen(Color.FromArgb(GradientColors[k][0], GradientColors[k][1], GradientColors[k][2]), 1); g.DrawEllipse(pen, x, y, 1, 1); } } } } m.Save("bound.png", ImageFormat.Png); }
private void rbIris_CheckedChanged(object sender, EventArgs e) { //btnbatch.Enabled = true; Tuple <double, double, double, double> Norm = Tuple.Create(10.0, 0.0, 3.0, 0.0); List <double[]> input = new List <double[]>(); List <double[]> output = new List <double[]>(); var t = Data.ReadData("IRIS_Train.csv", 4, 1, Norm, false); input = t.Item1; output = t.Item2; PerceptronNetwork network = new MLP.PerceptronNetwork(new int[] { 4, 5, 5, 1 }); NetworkController = new MLP.Network_Control(network, output, input, double.Parse(tbLearningRate.Text), false, Norm, 4, 1); tbStructure.Text = "4 5 5 1"; }