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#

  1. Neurons (States): Each neuron has a binary state, either 1 (active) or 1 (inactive). The state of all neurons is represented by a vector s. For a network of 3 neurons, the state vector might be:

    s=(111)
  2. Weights (Connections): Neurons are connected by weights, represented by a symmetric matrix W. For a 3-neuron network, the weight matrix might look like:

    W=(0w12w13w210w23w31w320)

    The diagonal elements are zero because a neuron does not connect to itself.

  3. Update Rule: To update the state of neuron i, we calculate the weighted sum of inputs from all other neurons:

    hi=jwijsj=(Ws)i

    If hi>0, the neuron becomes active (si=1). If hi<0, the neuron becomes inactive (si=1).


Example: Simple Hopfield Network#

Let’s consider a 3-neuron Hopfield network with the following weight matrix:

W=(011101110)

Initial State#

Assume the initial state of the network is:

s=(111)

Update Neurons#

We update each neuron based on the weighted inputs:

  1. Neuron 1: The input to neuron 1 is:

    h1=W11s1+W12s2+W13s3=01+1(1)+(1)1=2

    Since h1<0, the new state of neuron 1 is s1=1.

  2. Neuron 2: The input to neuron 2 is:

    h2=W21s1+W22s2+W23s3=11+0(1)+11=2

    Since h2>0, the new state of neuron 2 is s2=1.

  3. Neuron 3: The input to neuron 3 is:

    h3=W31s1+W32s2+W33s3=(1)1+1(1)+01=2

    Since h3<0, the new state of neuron 3 is s3=1.

New State#

After one round of updates, the new state of the network is:

s=(111)

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:

E=12i,jwijsisj=12sTWs

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 s.

  • Weights between neurons are represented by a matrix W.

  • 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.