Overview Recurrent neural networks Setting the weights Summary
COMP5400M Bio-Inspired Computing
Dr. Marc de Kamps
Lecture Hopfield 1
Copyright By PowCoder代写 加微信 powcoder
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks Setting the weights Summary
Today’s lecture
A reminder matrix-vector multiplication
Overview of today’s lecture
For the last two lectures (apart from the revision lecture next week), we will look at the final artificial neural network of this module, the Hopfield network:
How neuron outputs are updated using discrete time dynamics.
When convergence to a stable state is guaranteed.
How the weight matrix can be derived from a set of neural
activity patterns.
You will have the opportunity to practice these calculations in
today’s tutorial.
Tomorrow we will see how these properties relate to its ability to store memories.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks Setting the weights Summary
Today’s lecture
A reminder matrix-vector multiplication
Reminder: Matrix-vector multiplication
Suppose we have an N × N matrix wij and an N -vector xj . These can be multiplied to give an N-vector yi,
yi =wijxj =w11x1 +w12x2 +…+w1NxN .
or, more concisely, y = W x in matrix-vector notation.
Example for N = 3:
0 1 −2 1 3 10 31=−2 −230−1 1
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns
Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
Recurrent neural networks
Consider a neural network with the following features:
The network has N neurons/nodes.
It has feedback connections, i.e. it is a recurrent network.
There is persistent activity that changes with time, i.e. it is a dynamic network.
To focus on inherent changes in the network activity, also assume there are no inputs or outputs
Inputs can change network activity. Recall Beer’s paper
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns
Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
At any given time, the states of all neurons define the network’s activity pattern.
Each neuron can be in one of two states.
Similar to the strong self-connection case considered in Lecture
Denote these two states 1 or -1.
Not 0 or 1 as previously.
The current network activity can then be represented by a single
where each of the xi can be ±1.
x = (x1, x2, . . . , xN ) ,
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns
Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
The output of neuron i, xi, depends on its input signals. The weighted input is as per the standard perceptron:
si =wijxj
The output is 1 when the input is greater than or equal to
zero1, and -1 otherwise:
1 : si≥0 xi= −1 : si<0
Note we assume zero bias for simplicity.
1Note this differs from the usual Heaviside step function, for which the output is not defined when the input is exactly zero.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns
Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
Observe that the following network is not consistent, i.e. the outputs do not match their inputs:
This pattern is therefore not stable.
How can we update the pattern so that it is stable, i.e. all 1
neurons i have si ≥ 0, and all −1 neurons have si < 0?
Is this even possible?
Can convergence to a stable pattern be proven?
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns
Synchronous vs. asynchronous updates
Hopfield networks Energy and convergence
Synchronous vs. asynchronous updating
If at least one neuron’s input and output are not consistent, we need to change their outputs so that they do agree.
There are two ways to update the xi:
Synchronously:
All weighted sums si = j xj wij are evaluated at once. The xi are then assigned new values according si ≶ 0.
A neuron k is randomly chosen, sk is evaluated, and xk updated if required. The new xk is used for the next randomly-chosen neuron.
Asynchronously:
Note this is for discrete time steps (as opposed to continuous).
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns
Synchronous vs. asynchronous updates
Hopfield networks Energy and convergence
Consider updating the two-node network from two slides ago.
Synchronous updating:
t x1 x2 0 1 -1 1 -1 1 2 1 -1 3 -1 1
Asynchronous updating:
t k x1 x2 0 - 1 -1 1 1 -1 -1
t k x1 x2 0 - 1 -1 1211
Under asynchronous updating, a stable solution is quickly found, whereas synchronous updating leads to oscillatory behaviour.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
The Hopfield model
There is one class of recurrent neural network for which it is possible to update the pattern until it it stable. Furthermore, this can be proven.
This is called the Hopfield model after 1, building on earlier work by Little2 (and for this reason sometimes known as the Little-Hopfield network).
Today we just look at the calculations:
Practice will come in this afternoon’s tutorial.
Tomorrow we will see why this network is interesting.
1 J. Hopfield, Proc. Nat. Acad. Sci. 79, 2554 (1982). 2 W. Little, Math. Biosci. 19, 101 (1974).
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
Hopfield networks are recurrent neural networks with the following restrictions:
1. There are no self-connections, so each diagonal matrix element is zero1:
wii = 0 , i = 1 . . . N.
2. The weights are symmetric:
wij =wji,i,j=1...N.
If we wrote the weights as a matrix W, this could be
expressed as W = WT when WT is the transpose of W.
3. Updating is asynchronous.
1Note we do not use the summation convention in this module.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
Note there is only one line between neurons, with no arrows. This is because the weights are symmetric.
0 1 −2 W=103
Here, W is the weight matrix and gives a concise representation of the wij:
w11 w12 w13 W = w21 w22 w23
w31 w32 w33
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
Energy of a pattern x
Define the energy of the current state x as:
The factor of 21 is for convenience. Note the minus sign.
E can be negative, but is restricted to some finite range of values:
N is finite.
All of the wij are finite.
The xi are restricted to just the two values, −1 and 1.
Therefore E is bounded below, i.e. it cannot continue down to −∞; it must have some global minimum.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
Convergence under asynchronous updating
Suppose we randomly select neuron k for asynchronous update. Rearrange the sum to separate out all terms involving xk:
E = −1 xixjwij − 1 xixkwik − 1 xkxjwkj 2i,j̸=k 2i 2j
Note we are not double-counting the case i = j = k, because wkk = 0, so this term is zero anyway.
The first term does not involve xk, so it does not change during the update.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
Because wij is symmetric, the second and third terms are actually the same,
−1 xixkwik − 1 xkxjwkj = −xixkwki 2i2ji
Note the 21 vanishes after exploiting symmetry - this is why it was included in the first place.
Furthermore we can bring xk outside of the summation, −xxw =−xxw
ikki k iki ii
The sum on the right-hand side is the input to neuron k, i.e. sk = i xiwki.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Recurrent neural networks
Setting the weights Summary
Consistent activity patterns Synchronous vs. asynchronous updates Hopfield networks
Energy and convergence
Now consider two cases:
Ifxk =−1andsk =ixiwki ≥0,wewouldsetxk =1.
E would decrease1.
Ifxk =1andsk =ixiwkj <0,wewouldsetxk =−1.
E would decrease.
Therefore either E remains unchanged, or it decreases by some
finite amount.
However, E is also bounded below, so it cannot decrease for ever.
After a finite number of steps, there will be no further changes to the xi.
Therefore the procedure converges.
1Technically, if sk ≡ 0 E would not change, but such events are very rare.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Overview Recurrent neural networks Setting the weights Summary
Training the network
’s rule Stability of patterns
Initialising the weights
We have just seen that, given a weight matrix W , asynchronous updating leads to a stable activity patterns x.
How do we determine the wij in the first place? In other words, how do we train the matrix?
A convenient feature of Hopfield networks is that they are easy to train. Consider the set of p training patterns x(α),
P = {x(1), x(2), . . . x(p)} x(α) = {±1,±1,...±1}
Tomorrow we will see what these patterns represent, today we will just see how they are used to set the weights.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Overview Recurrent neural networks Setting the weights Summary
Training the network
Stability of patterns
For each training pattern x(α), construct the matrix 1 (α) (α)
w(α)=Nxixj :i̸=j ij 0 : i=j
This is the outer product of x(α), except for the diagonal elements.
Note that each W (α) is symmetrical.
The weight matrix is then the sum of all of these W(α),
W=W(α) or wij=w(α) ij
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Overview Recurrent neural networks Setting the weights Summary
Training the network
Stability of patterns
For example, consider N = 3 and these two patterns
x(1) = (−1, 1, −1) and Applying the generalised Hebb rule,
x(2) = (1, −1, 1)
0 −1 1 W(2) = 1 −1 0 −1
1 −1 0 1 −1 0
0 −1 1 33
W(1) = 1 −1 0 −1 and Therefore the sum is
W = W (1) + W (2) = 2 −1 0 −1 1 −1 0
0 −1 1 3
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Overview Recurrent neural networks Setting the weights Summary
Training the network ’s rule Stability of patterns
Stability of patterns
The matrix-vector notation can be used to quickly check if a pattern x is stable:
Note that row i of Wx is the input si to neuron i:
(Wx)i = wijxj = si
Ifxi andsi havethesamesignforalli(orsi =0and
xi = 1), then the pattern is stable.
You may find this easier/quicker than checking neuron-by-neuron.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Overview Recurrent neural networks Setting the weights Summary
Training the network ’s rule Stability of patterns
Consider W x for the following W and x:
0−1 1−1 −2
W x = − 3 0 − 3 1 = 3
31 −13 0 −1 −23
The sign of each vector element on the right hand side is the same
as in the original x vector. They are all consistent. The pattern x is stable.
Note this is actually W(1) and x(1): Training patterns are stable to their own matrix. We will return to this tomorrow.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
Overview Recurrent neural networks Setting the weights Summary
Today we have introduced the Hopfield model:
A recurrent neural network with no self-connections and
symmetric weights.
Under asynchronous updates, guaranteed to converge to a stable activity pattern.
Generate the weight matrix from a set of training patterns. Friday’s tutorial will go through some of these calculates for N = 4
and N = 5.
Next lecture we will see how this network can store memories.
Dr. Marc de Kamps
COMP5400M Bio-Inspired Computing
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com