Content-Addressable Memory
A CAM is a system that can take part of a pattern, and produce the most likely match from memory. A CAM for instance would be able to interpret these:
intel__gent
nueroscience
War+++loo
pa$sv0rd
1,3, ,7, ,1
A CAM system can find an input’s closest match to a set of known patterns. It retrieves data by directly comparing input queries with stored memory locations. Hopfield networks mimic the behavior of CAM in a biologically inspired way using neural networks.
Hopfield Networks
Suppose we have a network of neurons, each connected to all the others. We want this network to converge to the nearest of a set of targets or inputs.

The stored targets are a set of binary patterns, each of length :
where the th component is calculated using the weights and biases as:

One target is easy. What if we have many targets?
Another problem: The graph of the Hopfield net has cycles, so backpropagation won’t work.
Hopfield Energy
Hopfield energy is a scalar number that we compute for any network state . The dynamics are defined such that updating neurons makes decrease, so that the network falls into low-energy states, which correspond to the stored memories/patterns.
Hopfield energy is defined as:
where .
To minimize energy, we use gradient descent:
or
which is similar to the equation we saw earlier.
If :
If :
As a result, the gradient vector is:
where is a rank-1 matrix. We add the identity matrix to the right-hand side, so that the gradient of the diagonal weights is zero, to keep for gradient descent.
Over all targets, we have:
Thus:
where computes coactivation states between all pairs of neurons.
Because the input patterns are fixed, the coactivation matrix remains constant across iterations, so the gradient direction does not change, and repeated updates simply move linearly towards the steady-state solution, which is proportional to .
Example
Let’s say we have neurons and target patterns.
Stacking them into the data matrix :
Now, we compute the coactivation states between all pairs of neurons:
Then:
Using this to do weight update:
Let’s start with and . Then:
and we take biases .
Now, suppose we have a noisy cue:
- (the first bit should be for this to match )
Using the update rule:
Note that Hopfield networks are asynchronous, such that only one unit is updated at one time.
We have:
Then:
So the state is now (the first bit flipped).
For the second one:
The state stays as .
For the third one:
The state stays as .
Finally: