Application: Hopfield Neural Networks#
A Hopfield network is a type of recurrent neural network where all neurons are connected to each other. It is commonly used for associative memory—storing and recalling patterns. The network evolves to a stable state, recalling a stored pattern when given noisy or incomplete input. We can understand its behavior using matrix and vector operations.
Components of a Hopfield Network#
Neurons (States): Each neuron has a binary state, either
(active) or (inactive). The state of all neurons is represented by a vector . For a network of 3 neurons, the state vector might be:Weights (Connections): Neurons are connected by weights, represented by a symmetric matrix
. For a 3-neuron network, the weight matrix might look like:The diagonal elements are zero because a neuron does not connect to itself.
Update Rule: To update the state of neuron
, we calculate the weighted sum of inputs from all other neurons:If
, the neuron becomes active ( ). If , the neuron becomes inactive ( ).
Example: Simple Hopfield Network#
Let’s consider a 3-neuron Hopfield network with the following weight matrix:
Initial State#
Assume the initial state of the network is:
Update Neurons#
We update each neuron based on the weighted inputs:
Neuron 1: The input to neuron 1 is:
Since
, the new state of neuron 1 is .Neuron 2: The input to neuron 2 is:
Since
, the new state of neuron 2 is .Neuron 3: The input to neuron 3 is:
Since
, the new state of neuron 3 is .
New State#
After one round of updates, the new state of the network is:
Storing Patterns and Energy#
A Hopfield network stores specific patterns by adjusting the weights, and it evolves to minimize its energy. The energy of the network is defined as:
As the network updates, it reduces its energy until it reaches a stable state, which corresponds to one of the stored patterns.
Summary#
Neurons are represented by a state vector
.Weights between neurons are represented by a matrix
.Neurons update their states based on the weighted sum of inputs, which is a matrix-vector multiplication.
The network evolves to stable patterns by minimizing its energy function.
This is a basic introduction to the Hopfield network using matrix and vector operations.