Press "Enter" to skip to content

A Hopfield Network: Associative Memory

Interactive material for the NEUR0016 lecture Hippocampus and associative memory. A network of simple on/off neurons, one per pixel, stores pictures with a Hebbian learning rule and recalls them from noisy or half-hidden cues.

The interactive Hopfield network

A point-and-click version of the MATLAB demo from the lecture: draw or load a picture, store it, damage it with noise and watch the network recall the original as its energy falls; then store more pictures until recall fails.

Open the interactive Hopfield network →

The Hopfield network GUI after recalling a stored face from a cue with 30% noise, with the falling energy and the overlap with the stored memory

Download the interactive network (single HTML file, works offline) and open it in any web browser. The same GUI is also available as a Jupyter notebook: open it in the browser or download it (.ipynb) to run in Jupyter with numpy and ipywidgets.

The notebook

A step-by-step notebook: watch the network settle into a memory as its energy falls, find the spurious memories it settles into instead, and push it past its capacity by storing more and more patterns until recall fails.

Open the interactive notebook →

Download the notebook (.zip) to run it on your own computer: the zip holds the notebook, its data file (hopfield_images.npz, keep it in the same folder) and a short README. Install the libraries with pip install numpy matplotlib jupyter, open hopfield.ipynb in Jupyter and choose Run All.

Everything runs entirely in your web browser; nothing is installed and no data is sent to a server. The notebooks’ first load downloads about 30 MB and may take around 30 seconds; the interactive network opens instantly.