Hopfield Applet

 The applet below demonstrates the Hopfield network.

 A square grid is placed on the left side of the applet window. This grid represents a 10x10 input pattern (i.e. input vector size is 100). Clicking in a  white square of this grid convert this square to color black, and clicking a black square fills it with color white. A ‘white’ square means ‘-1’ input, and a ‘black square’ represents a ‘+1’ input.

 Buttons and other controls on the right of the grid controls the behaviour of the applet. ‘Clear Grid’ button clears the grid to the color white. ‘Save grid as’ button and the combo (choice) control allows us to save the state of the grid to the variables called ‘pattern 0’ and ‘pattern 1’. ‘Load grid from’ button and combo box right on the right of it restores the grid state from 8 predefined patterns (pattern of numbers from to 0 to 7) and 2 saved variables (pattern 0 and 1). ‘Add noise’ and the combo box on the right of it, adds the given number of black squares (‘1’ s) to the grid at random positions.

 Training set checkboxes below tells the network which patterns to learn while training.

 ‘Train’ button lets the applet to calculate the weights associated with the network. Notice that, the ‘Train’ button becomes ‘Recognize’ button after the training is completed.


  1. Click ‘Clear grid’ button to make sure the grid is empty.
  2. Select 3 patterns from the training set (excluding pattern 0 and 1) by using the checkboxes, e.g. select 0, 1 and 2.
  3. Click the ‘train’ button.
  4. Load the grid the ‘number 0’ pattern using ‘load grid from’ button with ‘number 0’ pattern from the combo box. Now the ‘number 0’ is displayed on the grid.
  5. Click ‘Add Noise’ button a few times to add some noise to the grid.
  6. Now click ‘Recognize’ button. We will see that the grid will converge to ‘number 0’ pattern. (assuming that we didn’t have add much noise to the pattern.)