/** * A simple main method to test the Hopfield neural network. * * @param args * Not used. */ static void Main(string[] args) { // Create the neural network. HopfieldNetwork network = new HopfieldNetwork(4); // This pattern will be trained bool[] pattern1 = { true, true, false, false }; // This pattern will be presented bool[] pattern2 = { true, false, false, false }; bool[] result; // train the neural network with pattern1 Console.WriteLine("Training Hopfield network with: " + FormatBoolean(pattern1)); network.Train(pattern1); // present pattern1 and see it recognized result = network.Present(pattern1); Console.WriteLine("Presenting pattern:" + FormatBoolean(pattern1) + ", and got " + FormatBoolean(result)); // Present pattern2, which is similar to pattern 1. Pattern 1 // should be recalled. result = network.Present(pattern2); Console.WriteLine("Presenting pattern:" + FormatBoolean(pattern2) + ", and got " + FormatBoolean(result)); }
public HopfieldRecForm() { InitializeComponent(); grid = new bool[HopfieldRecForm.GRID_X * HopfieldRecForm.GRID_Y]; this.hopfield = new HopfieldNetwork(HopfieldRecForm.GRID_X * HopfieldRecForm.GRID_Y); }