Filed under Math, Physics & Foundations

Implementing from scratch a Hopfield Network

A while ago I posted about Hopfield Networks. I wanted to further explore this theme by trying to implement this type of idea from scratch in python.

Here is the link to my code: GitHub

The whole thing is small enough to run in a browser, so here it is the same from-scratch network, 144 neurons and three stored patterns, with the Hebbian weights and the asynchronous update rule written out in the widget source.

The from-scratch network, live. Corrupt a stored pattern and press Recall: each neuron is updated one at a time in random order, taking the sign of its weighted input, and the energy falls until the state stops changing.

Some nice results are shown here:

The reconstruction of the images using associative memory of the network:

The weights of the hopfield network graph

#probability#kolmogorov