Skip to content
StackDecode
AI & ML Atlas
Neural NetworksalgorithmInteractive simulation

Hopfield Network Algorithm

A network that stores patterns and recalls a whole pattern from a damaged part.

The idea

Every neuron is connected to every other with symmetric weights set by a Hebbian rule from the stored patterns. Starting from a noisy pattern and updating neurons one by one always lowers an "energy" function, so the state slides down into the nearest stored pattern: content-addressable memory. Capacity is only about 0.14 N patterns for N neurons.

W = Σ xxᵀ / N, E = −½ sᵀ W s

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

Stored memories: T, H, X
  • on (+1)
  • off (−1)

Three letters (T, H, X) are stored in the weights. Here is one of them with 20% of its pixels flipped.

flips:
0
energy:
-22.34
1/6

Content-addressable memory: a damaged pattern is repaired by letting the neurons settle.

Step by step

  1. 1Store patterns by summing outer products to form the weight matrix (no self-connections).
  2. 2Start from a corrupted input pattern.
  3. 3Pick a neuron and set it to the sign of its weighted input.
  4. 4Repeat until no neuron changes.
  5. 5The final state is the recalled memory.

Where it is used

Associative memory, optimisation (the idea behind modern Hopfield layers).

Watch out for

Can fall into spurious mixtures; stores few patterns.

Related