Skip to main content
Sandbox Physics

D-X2 · A damaged picture finds a memory

Hopfield Associative Memory

How can a network recover a whole picture from a damaged cue? The stored pictures set connections that favor familiar combinations of cells. Starting from a damaged cue, each cell follows the influence of the others and the network energy falls. The final pattern can recover a memory or settle in a competing local minimum.

Scratch over a stored picture and let a network repair it one cell at a time. Add competing memories or scramble most of the cue to see when recall finds a different resting state.

Interactive modelHopfield Associative Memory
Error against selected picture00
Network energy00
Cells changed in this sweep00
Recall state00
Energy falls during this recall
Pictures stored in the weights

A recorded asynchronous recall is replayed. Cyan: computed energy; amber: current frame.

Scientific sources

Physics tutorial

A memory is a resting state of the network

BackgroundA familiar word can survive a missing letter. Hopfield’s model asks whether many simple units, each following its neighbors, can recover a familiar pattern from a damaged one.

Why it mattersThe memory sits in the connections between units. No separate program tells each cell which part of a heart or a lightning bolt it should draw.

Start with the essentials

Focus question
How can a network recover a whole picture from a damaged cue?
One-sentence intuition
Symmetric connections let asynchronous updates descend an energy function toward a stable pattern.

Core mathematical model

Pictures set the connections

wij=1N∑μ=1Pξiμξjμ,wii=0w_{ij}=\frac{1}{N}\sum_{\mu=1}^{P}\xi_i^{\mu}\xi_j^{\mu},\qquad w_{ii}=0

A stored picture assigns one binary value to each cell. A pair that often agrees gets a positive connection; a pair that often differs gets a negative one. The count of cells sets the normalization.

A cell follows its local field

si←sgn⁡ ⁣(∑jwijsj)s_i\leftarrow\operatorname{sgn}\!\left(\sum_j w_{ij}s_j\right)

One unit updates at a time, in a shuffled order. It follows the weighted influence of the other units. A zero sum leaves it unchanged.

Energy decreases when a unit changes

E=−12∑i,jwijsisj,ΔE=−(sinew−siold)∑jwijsj≤0E=-\frac12\sum_{i,j}w_{ij}s_i s_j,\qquad\Delta E=-(s_i^{\mathrm{new}}-s_i^{\mathrm{old}})\sum_j w_{ij}s_j\leq0

Symmetric weights and zero self-coupling make each allowed change lower the energy. The units eventually reach a state that no single update can improve.

Common difficulties

A minimum can be the wrong memory

Typical misconceptionOnce the energy stops falling, the intended picture must have been recovered.

Better mental modelThe energy can have many local minima. Correlated stored pictures can shift or merge them, and every picture has an inverted partner in this zero-threshold model.

Run the experiment

  1. 01

    Watch the repair

    Choose Repair a scratched heart and follow the amber marker on the energy curve.

    What to observe: The damaged cells change as the energy falls. The recorded recall repeats so you can follow the same repair.
  2. 02

    Give it a different clue

    Choose Recall lightning, then drag over part of the picture.

    What to observe: Release the pointer to start a new recall from your drawing. The connections stay fixed during recall.
  3. 03

    Let memories compete

    Choose Competing pictures and inspect the final error.

    What to observe: The correlated patterns can pull the network into a resting state that differs from the selected picture.
  4. 04

    Try the inverted picture

    Choose An inverted memory.

    What to observe: The network can settle on the inverted picture, which has the same energy as its original.
FeedbackSomething broken, confusing, or missing on this page?Tell us
What kind of feedback?

Sent with this page’s address, its Lab ID, the site language and your device type. Please leave out personal details. Feedback is kept for up to 12 months.Privacy policy