Hopfield network – an auto-associative memory

  1. Pattern completion: click Caswell, Store pattern, set noise to 30%, Add noise, then Run. The face is recalled and the energy falls to the memory's level.
  2. Partial cue: with the face stored, click Caswell (half) (or Erase lower half) and run – the missing half is filled in.
  3. Several memories: Reset weights, store A, B and C, then load one, add 20% noise and run. Watch the overlap bars: which memory does it fall into? The letters are mostly white, so they overlap heavily and B and C come back blotchy. Tick Brightness bias (Settings) and try again – now each letter is recalled cleanly.
  4. Too many memories: keep storing (letters, faces, Store 10 random). Recall gets worse, stored patterns stop being stable and the network settles into spurious mixtures. Similar images such as letters interfere far sooner than random patterns (capacity ≈ 0.14 × number of neurons).
  5. Inverted memories: Invert a stored pattern and run – the negative of every memory is also stable (overlap −1).
  6. Synchronous v. asynchronous: synchronous updating (every neuron at once, as in the original MATLAB demo) is fast but can oscillate; asynchronous updating (one neuron at a time) always reduces the energy.

Each pixel is a neuron: white = active (+1), black = silent (−1). Every neuron is connected to every other neuron with symmetric weights (no self-connections) – a model of the recurrent collaterals of CA3.

Learning (Hebb rule, as in the MATLAB demo): for each stored image ξ with mean m, wij += (ξi − m)(ξj − m) / (n(1 − m²)), where n = N × N neurons. This is the MATLAB rule for 0/1 units, rewritten for ±1 units. Subtracting the mean stops similar images (letters are mostly white) from all looking alike to the network.

Recall: each neuron sums its input hi = Σj wij sj + b and becomes active if hi > 0, silent if hi < 0 (unchanged if exactly 0). The bias b is 0 in the classic network; the Brightness bias setting makes it the average brightness of the stored images. Energy E = −½ Σij wij si sj − b Σi si can only fall with asynchronous updates, so the network rolls downhill into a stable state (an attractor). Overlap with memory μ is (1/n) Σi ξμi si: +1 identical, 0 unrelated, −1 inverted.

Hopfield (1982) PNAS 79:2554; Amit, Gutfreund & Sompolinsky (1985) on capacity (≈ 0.14 n random patterns). Keyboard: Space run/pause, → step, S store, N add noise, H erase half, I invert, R random.

Network

Pattern

Click or drag on the grid to draw.

Memory

Cue

Noise30%
Speed

Stored memories – click one to load it into the grid

Nothing stored yet – choose a pattern and click Store pattern.

Energy

Overlap with each stored memory

Settings