// Main() // -------------------------------------------------------------------------------------------- private static void MakeData(string dataFile, int numLines) { var weights = new[] { -0.1, 0.2, -0.3, 0.4, -0.5, 0.6, -0.7, 0.8, -0.9, 1.0, -1.1, 1.2, -1.3, 1.4, -1.5, 1.6, -1.7, 1.8, -1.9, 2.0, -0.5, 0.6, -0.7, 0.8, -0.9, 1.5, -1.4, 1.3, -1.2, 1.1, -1.0, 0.9, -0.8, 0.7, -0.6, 0.5, -0.4, 0.3, -0.2, 0.1, 0.1, -0.3, 0.6 }; var nn = new NeuralNetwork(4, 5, 3); nn.SetWeights(weights); var ofs = new FileStream(dataFile, FileMode.Create); var sw = new StreamWriter(ofs); for (int i = 0; i < numLines; ++i) { var inputs = new double[4]; for (int j = 0; j < inputs.Length; ++j) inputs[j] = _rnd.Next(1, 10); double[] outputs = nn.ComputeOutputs(inputs); string color = ""; int idx = Helpers.IndexOfLargest(outputs); if (idx == 0) { color = "red"; } else if (idx == 1) { color = "green"; } else if (idx == 2) { color = "blue"; } sw.WriteLine(inputs[0].ToString("F1") + " " + inputs[1].ToString("F1") + " " + inputs[2].ToString("F1") + " " + inputs[3].ToString("F1") + " " + color); } sw.Close(); ofs.Close(); }