public void Print(Perceptron p) { double guess = p.FeedForwad(Inputs); double guessRounded = Math.Round(guess); double error = Output - guess; bool isCorrect = guessRounded == Output; PrintColored("Inputs: [", ConsoleColor.White); for (int i = 0; i < Inputs.Length; i++) { string str = Inputs[i].ToString(); if (i < Inputs.Length - 1) { str += ","; } PrintColored(str.ToString(), ConsoleColor.Cyan); } PrintColored("]\nGuess: ", ConsoleColor.White); PrintColored(guessRounded.ToString(), isCorrect ? ConsoleColor.Green : ConsoleColor.DarkRed); if (!isCorrect) { PrintColored(string.Format(" ({0})", Output), ConsoleColor.Yellow); } PrintColored("\nError: ", ConsoleColor.White); PrintColored(error + "\n\n", isCorrect ? ConsoleColor.Green : ConsoleColor.Red); }
static void Main(string[] args) { Perceptron p = new Perceptron(2); DataSet[] data = TrainingData.And; p.TrainWithDataSet(data); for (int i = 0; i < data.Length; i++) { data[i].Print(p); } }