
 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 1
Lecture 7
Lecture 7
Artificial neural networks:
Artificial neural networks:
Supervised learning
Supervised learning
 Introduction, or how the brain works
Introduction, or how the brain works
 The neuron as a simple computing element
The neuron as a simple computing element
 The perceptron
The perceptron
 Multilayer neural networks
Multilayer neural networks
 Accelerated learning in multilayer neural networks
Accelerated learning in multilayer neural networks
 The Hopfield network
The Hopfield network
 Bidirectional associative memories (BAM)
Bidirectional associative memories (BAM)
 Summary
Summary

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 2
Introduction, or how the brain works
Introduction, or how the brain works
Machine learning involves adaptive mechanisms
Machine learning involves adaptive mechanisms
that enable computers to learn from experience,
that enable computers to learn from experience,
learn by example and learn by analogy. Learning
learn by example and learn by analogy. Learning
capabilities can improve the performance of an
capabilities can improve the performance of an
intelligent system over time. The most popular
intelligent system over time. The most popular
approaches to machine learning are
approaches to machine learning are artificial
artificial
neural networks
neural networks and
and genetic algorithms
genetic algorithms. This
. This
lecture is dedicated to neural networks.
lecture is dedicated to neural networks.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 3
 A
A neural network
neural network can be defined as a model of
can be defined as a model of
reasoning based on the human brain. The brain
reasoning based on the human brain. The brain
consists of a densely interconnected set of nerve
consists of a densely interconnected set of nerve
cells, or basic information-processing units, called
cells, or basic information-processing units, called
neurons
neurons.
.
 The human brain incorporates nearly 10 billion
The human brain incorporates nearly 10 billion
neurons and 60 trillion connections,
neurons and 60 trillion connections, synapses
synapses,
,
between them. By using multiple neurons
between them. By using multiple neurons
simultaneously, the brain can perform its functions
simultaneously, the brain can perform its functions
much faster than the fastest computers in existence
much faster than the fastest computers in existence
today.
today.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 4
 Each neuron has a very simple structure, but an
Each neuron has a very simple structure, but an
army of such elements constitutes a tremendous
army of such elements constitutes a tremendous
processing power.
processing power.
 A neuron consists of a cell body,
A neuron consists of a cell body, soma
soma, a number of
, a number of
fibers called
fibers called dendrites
dendrites, and a single long fiber
, and a single long fiber
called the
called the axon
axon.
.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 5
Biological neural network
Biological neural network
Soma Soma
Synapse
Synapse
Dendrites
Axon
Synapse
Dendrites
Axon

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 6
 Our brain can be considered as a highly complex,
Our brain can be considered as a highly complex,
non-linear and parallel information-processing
non-linear and parallel information-processing
system.
system.
 Information is stored and processed in a neural
Information is stored and processed in a neural
network simultaneously throughout the whole
network simultaneously throughout the whole
network, rather than at specific locations. In other
network, rather than at specific locations. In other
words, in neural networks, both data and its
words, in neural networks, both data and its
processing are
processing are global
global rather than local.
rather than local.
 Learning is a fundamental and essential
Learning is a fundamental and essential
characteristic of biological neural networks. The
characteristic of biological neural networks. The
ease with which they can learn led to attempts to
ease with which they can learn led to attempts to
emulate a biological neural network in a computer.
emulate a biological neural network in a computer.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 7
 An artificial neural network consists of a number of
An artificial neural network consists of a number of
very simple processors, also called
very simple processors, also called neurons
neurons, which
, which
are analogous to the biological neurons in the brain.
are analogous to the biological neurons in the brain.
 The neurons are connected by weighted links
The neurons are connected by weighted links
passing signals from one neuron to another.
passing signals from one neuron to another.
 The output signal is transmitted through the
The output signal is transmitted through the
neuron’s outgoing connection. The outgoing
neuron’s outgoing connection. The outgoing
connection splits into a number of branches that
connection splits into a number of branches that
transmit the same signal. The outgoing branches
transmit the same signal. The outgoing branches
terminate at the incoming connections of other
terminate at the incoming connections of other
neurons in the network.
neurons in the network.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 8
Architecture of a typical artificial neural network
Architecture of a typical artificial neural network
Input Layer Output Layer
Middle Layer
I
n
p
u
t
S
i
g
n
a
l
s
O
u
t
p
u
t
S
i
g
n
a
l
s

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 9
Analogy between biological and
Analogy between biological and
artificial neural networks
artificial neural networks

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 10
The neuron as a simple computing element
The neuron as a simple computing element
Diagram of a neuron
Diagram of a neuron
Neuron Y
Input Signals
x1
x2
xn
Output Signals
Y
Y
Y
w2
w1
wn
Weights

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 11
 The neuron computes the weighted sum of the input
The neuron computes the weighted sum of the input
signals and compares the result with a
signals and compares the result with a threshold
threshold
value
value,
, 
. If the net input is less than the threshold,
. If the net input is less than the threshold,
the neuron output is –1. But if the net input is greater
the neuron output is –1. But if the net input is greater
than or equal to the threshold, the neuron becomes
than or equal to the threshold, the neuron becomes
activated and its output attains a value +1.
activated and its output attains a value +1.
 The neuron uses the following transfer or
The neuron uses the following transfer or activation
activation
function
function:
:
 This type of activation function is called a
This type of activation function is called a sign
sign
function
function.
.



n
i
i
iw
x
X
1 









X
X
Y
if
,
1
if
,
1

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 12
Activation functions of a neuron
Activation functions of a neuron
Step function Sign function
+1
-1
0
+1
-1
0
X
Y
X
Y
+1
-1
0 X
Y
Sigm oid function
+1
-1
0 X
Y
L inear function






0
if
,
0
0
if
,
1
X
X
Y step








0
if
,
1
0
if
,
1
X
X
Y sign
X
sigmoid
e
Y



1
1
X
Y linear


 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 13
Can a single neuron learn a task?
Can a single neuron learn a task?
 In 1958,
In 1958, Frank Rosenblatt
Frank Rosenblatt introduced a training
introduced a training
algorithm that provided the first procedure for
algorithm that provided the first procedure for
training a simple ANN: a
training a simple ANN: a perceptron
perceptron.
.
 The perceptron is the simplest form of a neural
The perceptron is the simplest form of a neural
network. It consists of a single neuron with
network. It consists of a single neuron with
adjustable
adjustable synaptic weights and a
synaptic weights and a hard limiter
hard limiter.
.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 14
T
h
r
e
s
h
o
l
d
I
n
p
u
t
s
x
1
x
2
O
u
t
p
u
t
Y

H
a
r
d
L
i
m
i
t
e
r
w
2
w
1
L
i
n
e
a
r
C
o
m
b
i
n
e
r

Single-layer two-input perceptron
Single-layer two-input perceptron

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 15
The Perceptron
The Perceptron
 The operation of Rosenblatt’s perceptron is based
The operation of Rosenblatt’s perceptron is based
on the
on the McCulloch and Pitts neuron model
McCulloch and Pitts neuron model. The
. The
model consists of a linear combiner followed by a
model consists of a linear combiner followed by a
hard limiter.
hard limiter.
 The weighted sum of the inputs is applied to the
The weighted sum of the inputs is applied to the
hard limiter, which produces an output equal to +1
hard limiter, which produces an output equal to +1
if its input is positive and
if its input is positive and 
1 if it is negative.
1 if it is negative.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 16
 The aim of the perceptron is to classify inputs,
The aim of the perceptron is to classify inputs,
x
x1
1,
, x
x2
2, . . .,
, . . ., x
xn
n, into one of two classes, say
, into one of two classes, say
A
A1
1 and
and A
A2
2.
.
 In the case of an elementary perceptron, the n-
In the case of an elementary perceptron, the n-
dimensional space is divided by a
dimensional space is divided by a hyperplane
hyperplane into
into
two decision regions. The hyperplane is defined by
two decision regions. The hyperplane is defined by
the
the linearly separable
linearly separable function
function:
:
0
1





n
i
i
iw
x

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 17
Linear separability in the perceptrons
Linear separability in the perceptrons
x1
x2
Class A2
Class A1
1
2
x1w1 + x2w2
  = 0
(a) Two-input perceptron. (b) Three-input perceptron.
x2
x1
x3
x1w1 + x2w2 + x3w3
  = 0
1
2

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 18
This is done by making small adjustments in the
This is done by making small adjustments in the
weights to reduce the difference between the actual
weights to reduce the difference between the actual
and desired outputs of the perceptron. The initial
and desired outputs of the perceptron. The initial
weights are randomly assigned, usually in the range
weights are randomly assigned, usually in the range
[
[
0.5, 0.5], and then updated to obtain the output
0.5, 0.5], and then updated to obtain the output
consistent with the training examples.
consistent with the training examples.
How does the perceptron learn its classification
How does the perceptron learn its classification
tasks?
tasks?

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 19
 If at iteration
If at iteration p
p, the actual output is
, the actual output is Y
Y(
(p
p) and the
) and the
desired output is
desired output is Y
Yd
d (
(p
p), then the error is given by:
), then the error is given by:
where
where p
p = 1, 2, 3, . . .
= 1, 2, 3, . . .
Iteration
Iteration p
p here refers to the
here refers to the p
pth training example
th training example
presented to the perceptron.
presented to the perceptron.
 If the error,
If the error, e
e(
(p
p), is positive, we need to increase
), is positive, we need to increase
perceptron output
perceptron output Y
Y(
(p
p), but if it is negative, we
), but if it is negative, we
need to decrease
need to decrease Y
Y(
(p
p).
).
)
(
)
(
)
( p
Y
p
Y
p
e d 


 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 20
The perceptron learning rule
The perceptron learning rule
where
where p
p = 1, 2, 3, . . .
= 1, 2, 3, . . .

 is the
is the learning rate
learning rate, a positive constant less than
, a positive constant less than
unity.
unity.
The perceptron learning rule was first proposed by
The perceptron learning rule was first proposed by
Rosenblatt
Rosenblatt in 1960. Using this rule we can derive
in 1960. Using this rule we can derive
the perceptron training algorithm for classification
the perceptron training algorithm for classification
tasks.
tasks.
)
(
)
(
)
(
)
1
( p
e
p
x
p
w
p
w i
i
i 



 

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 21
Step 1
Step 1: Initialisation
: Initialisation
Set initial weights
Set initial weights w
w1
1,
, w
w2
2,…,
,…, w
wn
n and threshold
and threshold 

to random numbers in the range [
to random numbers in the range [
0.5, 0.5].
0.5, 0.5].
If the error,
If the error, e
e(
(p
p), is positive, we need to increase
), is positive, we need to increase
perceptron output
perceptron output Y
Y(
(p
p), but if it is negative, we
), but if it is negative, we
need to decrease
need to decrease Y
Y(
(p
p).
).
Perceptron’s training algorithm
Perceptron’s training algorithm

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 22
Step 2
Step 2: Activation
: Activation
Activate the perceptron by applying inputs
Activate the perceptron by applying inputs x
x1
1(
(p
p),
),
x
x2
2(
(p
p),…,
),…, x
xn
n(
(p
p) and desired output
) and desired output Y
Yd
d (
(p
p).
).
Calculate the actual output at iteration
Calculate the actual output at iteration p
p = 1
= 1
where
where n
n is the number of the perceptron inputs,
is the number of the perceptron inputs,
and
and step
step is a step activation function.
is a step activation function.
Perceptron’s training algorithm (continued)
Perceptron’s training algorithm (continued)










 

n
i
i
i p
w
p
x
step
p
Y
1
)
(
)
(
)
(

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 23
Step 3
Step 3: Weight training
: Weight training
Update the weights of the perceptron
Update the weights of the perceptron
where
where 
w
wi
i(
(p
p) is the weight correction at iteration
) is the weight correction at iteration p
p.
.
The weight correction is computed by the
The weight correction is computed by the delta
delta
rule
rule:
:
Step 4
Step 4: Iteration
: Iteration
Increase iteration
Increase iteration p
p by one, go back to
by one, go back to Step 2
Step 2 and
and
repeat the process until convergence.
repeat the process until convergence.
)
(
)
(
)
1
( p
w
p
w
p
w i
i
i 



Perceptron’s training algorithm (continued)
Perceptron’s training algorithm (continued)
)
(
)
(
)
( p
e
p
x
p
w i
i 





 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 24
Example of perceptron learning: the logical operation
Example of perceptron learning: the logical operation AND
AND
Inputs
x1 x2
0
0
1
1
0
1
0
1
0
0
0
Epoch
Desired
output
Yd
1
Initial
weights
w1 w2
1
0.3
0.3
0.3
0.2
 0.1
 0.1
 0.1
 0.1
0
0
1
0
Actual
output
Y
Error
e
0
0
 1
1
Final
weights
w1 w2
0.3
0.3
0.2
0.3
 0.1
 0.1
 0.1
0.0
0
0
1
1
0
1
0
1
0
0
0
2
1
0.3
0.3
0.3
0.2
0
0
1
1
0
0
 1
0
0.3
0.3
0.2
0.2
0.0
0.0
0.0
0.0
0
0
1
1
0
1
0
1
0
0
0
3
1
0.2
0.2
0.2
0.1
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0
0
1
0
0
0
 1
1
0.2
0.2
0.1
0.2
0.0
0.0
0.0
0.1
0
0
1
1
0
1
0
1
0
0
0
4
1
0.2
0.2
0.2
0.1
0.1
0.1
0.1
0.1
0
0
1
1
0
0
 1
0
0.2
0.2
0.1
0.1
0.1
0.1
0.1
0.1
0
0
1
1
0
1
0
1
0
0
0
5
1
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0
0
0
1
0
0
0
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0
Threshold:  = 0.2; learning rate:  = 0.1

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 25
Two-dimensional plots of basic logical operations
Two-dimensional plots of basic logical operations
x1
x2
1
(a) AND (x1
 x2)
1
x1
x2
1
1
(b) OR (x1
 x2)
x1
x2
1
1
(c) Exclusive-OR
(x1
 x2)
0
0 0
A perceptron can learn the operations
A perceptron can learn the operations AND
AND and
and OR
OR,
,
but not
but not Exclusive-OR
Exclusive-OR.
.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 26
Multilayer neural networks
Multilayer neural networks
 A multilayer perceptron is a feedforward neural
A multilayer perceptron is a feedforward neural
network with one or more hidden layers.
network with one or more hidden layers.
 The network consists of an
The network consists of an input layer
input layer of source
of source
neurons, at least one middle or
neurons, at least one middle or hidden layer
hidden layer of
of
computational neurons, and an
computational neurons, and an output layer
output layer of
of
computational neurons.
computational neurons.
 The input signals are propagated in a forward
The input signals are propagated in a forward
direction on a layer-by-layer basis.
direction on a layer-by-layer basis.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 27
Multilayer perceptron with two hidden layers
Multilayer perceptron with two hidden layers
Input
layer
First
hidden
layer
Second
hidden
layer
Output
layer
O
u
t
p
u
t
S
i
g
n
a
l
s
I
n
p
u
t
S
i
g
n
a
l
s

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 28
What does the middle layer hide?
What does the middle layer hide?
 A hidden layer “hides” its desired output.
A hidden layer “hides” its desired output.
Neurons in the hidden layer cannot be observed
Neurons in the hidden layer cannot be observed
through the input/output behaviour of the network.
through the input/output behaviour of the network.
There is no obvious way to know what the desired
There is no obvious way to know what the desired
output of the hidden layer should be.
output of the hidden layer should be.
 Commercial ANNs incorporate three and
Commercial ANNs incorporate three and
sometimes four layers, including one or two
sometimes four layers, including one or two
hidden layers. Each layer can contain from 10 to
hidden layers. Each layer can contain from 10 to
1000 neurons. Experimental neural networks may
1000 neurons. Experimental neural networks may
have five or even six layers, including three or
have five or even six layers, including three or
four hidden layers, and utilise millions of neurons.
four hidden layers, and utilise millions of neurons.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 29
Back-propagation neural network
Back-propagation neural network
 Learning in a multilayer network proceeds the
Learning in a multilayer network proceeds the
same way as for a perceptron.
same way as for a perceptron.
 A training set of input patterns is presented to the
A training set of input patterns is presented to the
network.
network.
 The network computes its output pattern, and if
The network computes its output pattern, and if
there is an error
there is an error 
 or in other words a difference
or in other words a difference
between actual and desired output patterns
between actual and desired output patterns 
 the
the
weights are adjusted to reduce this error.
weights are adjusted to reduce this error.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 30
 In a back-propagation neural network, the learning
In a back-propagation neural network, the learning
algorithm has two phases.
algorithm has two phases.
 First, a training input pattern is presented to the
First, a training input pattern is presented to the
network input layer. The network propagates the
network input layer. The network propagates the
input pattern from layer to layer until the output
input pattern from layer to layer until the output
pattern is generated by the output layer.
pattern is generated by the output layer.
 If this pattern is different from the desired output,
If this pattern is different from the desired output,
an error is calculated and then propagated
an error is calculated and then propagated
backwards through the network from the output
backwards through the network from the output
layer to the input layer. The weights are modified
layer to the input layer. The weights are modified
as the error is propagated.
as the error is propagated.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 31
Three-layer back-propagation neural network
Three-layer back-propagation neural network
Input
layer
xi
x1
x2
xn
1
2
i
n
Output
layer
1
2
k
l
yk
y1
y2
yl
Input signals
Error signals
wjk
Hidden
layer
wij
1
2
j
m

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 32
Step 1
Step 1: Initialisation
: Initialisation
Set all the weights and threshold levels of the
Set all the weights and threshold levels of the
network to random numbers uniformly
network to random numbers uniformly
distributed inside a small range:
distributed inside a small range:
where
where F
Fi
i is the total number of inputs of neuron
is the total number of inputs of neuron i
i
in the network. The weight initialisation is done
in the network. The weight initialisation is done
on a neuron-by-neuron basis.
on a neuron-by-neuron basis.
The back-propagation training algorithm
The back-propagation training algorithm










i
i F
F
4
.
2
,
4
.
2

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 33
Step 2
Step 2: Activation
: Activation
Activate the back-propagation neural network by
Activate the back-propagation neural network by
applying inputs
applying inputs x
x1
1(
(p
p),
), x
x2
2(
(p
p),…,
),…, x
xn
n(
(p
p) and desired
) and desired
outputs
outputs y
yd
d,1
,1(
(p
p),
), y
yd
d,2
,2(
(p
p),…,
),…, y
yd
d,
,n
n(
(p
p).
).
(
(a
a) Calculate the actual outputs of the neurons in
) Calculate the actual outputs of the neurons in
the hidden layer:
the hidden layer:
where
where n
n is the number of inputs of neuron
is the number of inputs of neuron j
j in the
in the
hidden layer, and
hidden layer, and sigmoid
sigmoid is the
is the sigmoid
sigmoid activation
activation
function.
function.











 

j
n
i
ij
i
j p
w
p
x
sigmoid
p
y
1
)
(
)
(
)
(

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 34
(
(b
b) Calculate the actual outputs of the neurons in
) Calculate the actual outputs of the neurons in
the output layer:
the output layer:
where
where m
m is the number of inputs of neuron
is the number of inputs of neuron k
k in the
in the
output layer.
output layer.











 

k
m
j
jk
jk
k p
w
p
x
sigmoid
p
y
1
)
(
)
(
)
(
Step 2
Step 2: Activation (continued)
: Activation (continued)

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 35
Step 3
Step 3: Weight training
: Weight training
Update the weights in the back-propagation network
Update the weights in the back-propagation network
propagating backward the errors associated with
propagating backward the errors associated with
output neurons.
output neurons.
(
(a
a) Calculate the error gradient for the neurons in the
) Calculate the error gradient for the neurons in the
output layer:
output layer:
where
where
Calculate the weight corrections:
Calculate the weight corrections:
Update the weights at the output neurons:
Update the weights at the output neurons:
  )
(
)
(
1
)
(
)
( p
e
p
y
p
y
p k
k
k
k 




)
(
)
(
)
( , p
y
p
y
p
e k
k
d
k 

)
(
)
(
)
( p
p
y
p
w k
j
jk 
 



)
(
)
(
)
1
( p
w
p
w
p
w jk
jk
jk 




 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 36
(
(b
b) Calculate the error gradient for the neurons in
) Calculate the error gradient for the neurons in
the hidden layer:
the hidden layer:
Calculate the weight corrections:
Calculate the weight corrections:
Update the weights at the hidden neurons:
Update the weights at the hidden neurons:
)
(
)
(
)
(
1
)
(
)
(
1
]
[ p
w
p
p
y
p
y
p jk
l
k
k
j
j
j 




 

)
(
)
(
)
( p
p
x
p
w j
i
ij 
 



)
(
)
(
)
1
( p
w
p
w
p
w ij
ij
ij 



Step 3
Step 3: Weight training (continued)
: Weight training (continued)

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 37
Step 4
Step 4: Iteration
: Iteration
Increase iteration
Increase iteration p
p by one, go back to
by one, go back to Step 2
Step 2 and
and
repeat the process until the selected error criterion
repeat the process until the selected error criterion
is satisfied.
is satisfied.
As an example, we may consider the three-layer
As an example, we may consider the three-layer
back-propagation network. Suppose that the
back-propagation network. Suppose that the
network is required to perform logical operation
network is required to perform logical operation
Exclusive-OR
Exclusive-OR. Recall that a single-layer perceptron
. Recall that a single-layer perceptron
could not do this operation. Now we will apply the
could not do this operation. Now we will apply the
three-layer net.
three-layer net.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 38
Three-layer network for solving the
Three-layer network for solving the
Exclusive-OR operation
Exclusive-OR operation
y5
5
x1 3
1
x2
Input
layer
Output
layer
Hidden layer
4
2

3
w13
w24
w23
w24
w35
w45

4

5
 1
 1
 1

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 39
 The effect of the threshold applied to a neuron in the
The effect of the threshold applied to a neuron in the
hidden or output layer is represented by its weight,
hidden or output layer is represented by its weight, 
,
,
connected to a fixed input equal to
connected to a fixed input equal to 
1.
1.
 The initial weights and threshold levels are set
The initial weights and threshold levels are set
randomly as follows:
randomly as follows:
w
w13
13 = 0.5,
= 0.5, w
w14
14 = 0.9,
= 0.9, w
w23
23 = 0.4,
= 0.4, w
w24
24 = 1.0,
= 1.0, w
w35
35 =
= 
1.2,
1.2,
w
w45
45 = 1.1,
= 1.1, 
3
3 = 0.8,
= 0.8, 
4
4 =
= 
0.1 and
0.1 and 
5
5 = 0.3.
= 0.3.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 40
 We consider a training set where inputs
We consider a training set where inputs x
x1
1 and
and x
x2
2 are
are
equal to 1 and desired output
equal to 1 and desired output y
yd
d,5
,5 is 0. The actual
is 0. The actual
outputs of neurons 3 and 4 in the hidden layer are
outputs of neurons 3 and 4 in the hidden layer are
calculated as
calculated as
  5250
.
0
1
/
1
)
( )
8
.
0
1
4
.
0
1
5
.
0
1
(
3
23
2
13
1
3 





 





e
w
x
w
x
sigmoid
y
  8808
.
0
1
/
1
)
( )
1
.
0
1
0
.
1
1
9
.
0
1
(
4
24
2
14
1
4 





 





e
w
x
w
x
sigmoid
y
 Now the actual output of neuron 5 in the output layer
Now the actual output of neuron 5 in the output layer
is determined as:
is determined as:
 Thus, the following error is obtained:
Thus, the following error is obtained:
  5097
.
0
1
/
1
)
( )
3
.
0
1
1
.
1
8808
.
0
2
.
1
5250
.
0
(
5
45
4
35
3
5 





 






e
w
y
w
y
sigmoid
y
5097
.
0
5097
.
0
0
5
5
, 




 y
y
e d

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 41
 The next step is weight training. To update the
The next step is weight training. To update the
weights and threshold levels in our network, we
weights and threshold levels in our network, we
propagate the error,
propagate the error, e
e, from the output layer
, from the output layer
backward to the input layer.
backward to the input layer.
 First, we calculate the error gradient for neuron 5 in
First, we calculate the error gradient for neuron 5 in
the output layer:
the output layer:
1274
.
0
5097)
.
0
(
0.5097)
(1
0.5097
)
1
( 5
5
5 







 e
y
y

 Then we determine the weight corrections assuming
Then we determine the weight corrections assuming
that the learning rate parameter,
that the learning rate parameter, 
, is equal to 0.1:
, is equal to 0.1:
0112
.
0
)
1274
.
0
(
8808
.
0
1
.
0
5
4
45 








 
 y
w
0067
.
0
)
1274
.
0
(
5250
.
0
1
.
0
5
3
35 








 
 y
w
0127
.
0
)
1274
.
0
(
)
1
(
1
.
0
)
1
( 5
5 











 


 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 42
 Next we calculate the error gradients for neurons 3
Next we calculate the error gradients for neurons 3
and 4 in the hidden layer:
and 4 in the hidden layer:
 We then determine the weight corrections:
We then determine the weight corrections:
0381
.
0
)
2
.
1
(
0.1274)
(
0.5250)
(1
0.5250
)
1
( 35
5
3
3
3 










 w
y
y 

0.0147
.1
1
4)
0.127
(
0.8808)
(1
0.8808
)
1
( 45
5
4
4
4 










 w
y
y 

0038
.
0
0381
.
0
1
1
.
0
3
1
13 






 
 x
w
0038
.
0
0381
.
0
1
1
.
0
3
2
23 






 
 x
w
0038
.
0
0381
.
0
)
1
(
1
.
0
)
1
( 3
3 










 

0015
.
0
)
0147
.
0
(
1
1
.
0
4
1
14 








 
 x
w
0015
.
0
)
0147
.
0
(
1
1
.
0
4
2
24 








 
 x
w
0015
.
0
)
0147
.
0
(
)
1
(
1
.
0
)
1
( 4
4 










 


 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 43
 At last, we update all weights and threshold:
At last, we update all weights and threshold:
5038
.
0
0038
.
0
5
.
0
13
13
13 




 w
w
w
8985
.
0
0015
.
0
9
.
0
14
14
14 




 w
w
w
4038
.
0
0038
.
0
4
.
0
23
23
23 




 w
w
w
9985
.
0
0015
.
0
0
.
1
24
24
24 




 w
w
w
2067
.
1
0067
.
0
2
.
1
35
35
35 






 w
w
w
0888
.
1
0112
.
0
1
.
1
45
45
45 




 w
w
w
7962
.
0
0038
.
0
8
.
0
3
3
3 








0985
.
0
0015
.
0
1
.
0
4
4
4 










3127
.
0
0127
.
0
3
.
0
5
5
5 








 The training process is repeated until the sum of
The training process is repeated until the sum of
squared errors is less than 0.001.
squared errors is less than 0.001.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 44
Learning curve for operation
Learning curve for operation Exclusive-OR
Exclusive-OR
0 50 100 150 200
101
Epoch
Sum-Squared
Error
Sum-Squared Network Error for 224 Epochs
100
10-1
10-2
10-3
10-4

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 45
Final results of three-layer network learning
Final results of three-layer network learning
Inputs
x1 x2
1
0
1
0
1
1
0
0
0
1
1
Desired
output
yd
0
0.0155
Actual
output
y5
Y
Error
e
Sum of
squared
errors
e
0.9849
0.9849
0.0175
 0.0155
0.0151
0.0151
 0.0175
0.0010

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 46
Network represented by McCulloch-Pitts model
Network represented by McCulloch-Pitts model
for solving the
for solving the Exclusive-OR
Exclusive-OR operation
operation
y5
5
x1 3
1
x2 4
2
+1.0
 1
 1
 1
+1.0
+1.0
+1.0
+1.5
+1.0
+0.5
+0.5
 2.0

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 47
(
(a
a) Decision boundary constructed by hidden neuron 3;
) Decision boundary constructed by hidden neuron 3;
(
(b
b) Decision boundary constructed by hidden neuron 4;
) Decision boundary constructed by hidden neuron 4;
(
(c
c) Decision boundaries constructed by the complete
) Decision boundaries constructed by the complete
three-layer network
three-layer network
x1
x2
1
(a)
1
x2
1
1
(b)
0
0
x1 + x2 – 1.5 = 0 x1 + x2 – 0.5 = 0
x1 x1
x2
1
1
(c)
0
Decision boundaries
Decision boundaries

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 48
Accelerated learning in multilayer
Accelerated learning in multilayer
neural networks
neural networks
 A multilayer network learns much faster when the
A multilayer network learns much faster when the
sigmoidal activation function is represented by a
sigmoidal activation function is represented by a
hyperbolic tangent
hyperbolic tangent:
:
where
where a
a and
and b
b are constants.
are constants.
Suitable values for
Suitable values for a
a and
and b
b are:
are:
a
a = 1.716 and
= 1.716 and b
b = 0.667
= 0.667
a
e
a
Y bX
h
tan


 
1
2

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 49
 We also can accelerate training by including a
We also can accelerate training by including a
momentum term
momentum term in the delta rule:
in the delta rule:
where
where 
 is a positive number (0
is a positive number (0 
 
 
 1) called the
1) called the
momentum constant
momentum constant. Typically, the momentum
. Typically, the momentum
constant is set to 0.95.
constant is set to 0.95.
This equation is called the
This equation is called the generalised delta rule
generalised delta rule.
.
)
(
)
(
)
1
(
)
( p
p
y
p
w
p
w k
j
jk
jk 

 








 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 50
Learning with momentum for operation
Learning with momentum for operation Exclusive-OR
Exclusive-OR
0 20 40 60 80 100 120
10-4
10-2
100
102
Epoch
Sum-Squared
Error
Training for 126 Epochs
0 100 140
-1
-0.5
0
0.5
1
1.5
Epoch
Learning
Rate
10-3
101
10-1
20 40 60 80 120

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 51
Learning with adaptive learning rate
Learning with adaptive learning rate
To accelerate the convergence and yet avoid the
To accelerate the convergence and yet avoid the
danger of instability, we can apply two heuristics:
danger of instability, we can apply two heuristics:
Heuristic 1
Heuristic 1
If the change of the sum of squared errors has the same
If the change of the sum of squared errors has the same
algebraic sign for several consequent epochs, then the
algebraic sign for several consequent epochs, then the
learning rate parameter,
learning rate parameter, 
, should be increased.
, should be increased.
Heuristic 2
Heuristic 2
If the algebraic sign of the change of the sum of
If the algebraic sign of the change of the sum of
squared errors alternates for several consequent
squared errors alternates for several consequent
epochs, then the learning rate parameter,
epochs, then the learning rate parameter, 
, should be
, should be
decreased.
decreased.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 52
 Adapting the learning rate requires some changes
Adapting the learning rate requires some changes
in the back-propagation algorithm.
in the back-propagation algorithm.
 If the sum of squared errors at the current epoch
If the sum of squared errors at the current epoch
exceeds the previous value by more than a
exceeds the previous value by more than a
predefined ratio (typically 1.04), the learning rate
predefined ratio (typically 1.04), the learning rate
parameter is decreased (typically by multiplying
parameter is decreased (typically by multiplying
by 0.7) and new weights and thresholds are
by 0.7) and new weights and thresholds are
calculated.
calculated.
 If the error is less than the previous one, the
If the error is less than the previous one, the
learning rate is increased (typically by multiplying
learning rate is increased (typically by multiplying
by 1.05).
by 1.05).

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 53
Learning with adaptive learning rate
Learning with adaptive learning rate
0 10 20 30 40 50 60 70 80 90 100
Epoch
Training for 103 Epochs
0 20 40 60 80 100 120
0
0.2
0.4
0.6
0.8
1
Epoch
Learning
Rate
10-4
10-2
100
102
Sum-Squared
Error
10-3
101
10-1

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 54
Learning with momentum and adaptive learning rate
Learning with momentum and adaptive learning rate
0 10 20 30 40 50 60 70 80
Epoch
Training for 85 Epochs
0 10 20 30 40 50 60 70 80 90
0
0.5
1
2.5
Epoch
Learning
Rate
10-4
10-2
100
102
Sum-Squared
Error
10-3
101
10-1
1.5
2

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 55
 Neural networks were designed on analogy with
Neural networks were designed on analogy with
the brain. The brain’s memory, however, works
the brain. The brain’s memory, however, works
by association. For example, we can recognise a
by association. For example, we can recognise a
familiar face even in an unfamiliar environment
familiar face even in an unfamiliar environment
within 100-200 ms. We can also recall a
within 100-200 ms. We can also recall a
complete sensory experience, including sounds
complete sensory experience, including sounds
and scenes, when we hear only a few bars of
and scenes, when we hear only a few bars of
music. The brain routinely associates one thing
music. The brain routinely associates one thing
with another.
with another.
The Hopfield Network
The Hopfield Network

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 56
 Multilayer neural networks trained with the back-
Multilayer neural networks trained with the back-
propagation algorithm are used for pattern
propagation algorithm are used for pattern
recognition problems. However, to emulate the
recognition problems. However, to emulate the
human memory’s associative characteristics we
human memory’s associative characteristics we
need a different type of network: a
need a different type of network: a recurrent
recurrent
neural network
neural network.
.
 A recurrent neural network has feedback loops
A recurrent neural network has feedback loops
from its outputs to its inputs. The presence of
from its outputs to its inputs. The presence of
such loops has a profound impact on the learning
such loops has a profound impact on the learning
capability of the network.
capability of the network.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 57
 The stability of recurrent networks intrigued
The stability of recurrent networks intrigued
several researchers in the 1960s and 1970s.
several researchers in the 1960s and 1970s.
However, none was able to predict which network
However, none was able to predict which network
would be stable, and some researchers were
would be stable, and some researchers were
pessimistic about finding a solution at all. The
pessimistic about finding a solution at all. The
problem was solved only in 1982, when
problem was solved only in 1982, when John
John
Hopfield
Hopfield formulated the physical principle of
formulated the physical principle of
storing information in a dynamically stable
storing information in a dynamically stable
network.
network.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 58
Single-layer
Single-layer n
n-neuron Hopfield network
-neuron Hopfield network
xi
x1
x2
xn
I
n
p
u
t
S
i
g
n
a
l
s
yi
y1
y2
yn
1
2
i
n
O
u
t
p
u
t
S
i
g
n
a
l
s

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 59
 The Hopfield network uses McCulloch and Pitts
The Hopfield network uses McCulloch and Pitts
neurons with the
neurons with the sign activation function
sign activation function as its
as its
computing element:
computing element:













X
Y
X
X
Y sign
if
,
if
,
1
0
if
,
1

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 60
 The current state of the Hopfield network is
The current state of the Hopfield network is
determined by the current outputs of all neurons,
determined by the current outputs of all neurons,
y
y1
1,
, y
y2
2, . . .,
, . . ., y
yn
n.
.
Thus, for a single-layer
Thus, for a single-layer n
n-neuron network, the state
-neuron network, the state
can be defined by the
can be defined by the state vector
state vector as:
as:















n
y
y
y

2
1
Y

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 61
 In the Hopfield network, synaptic weights between
In the Hopfield network, synaptic weights between
neurons are usually represented in matrix form as
neurons are usually represented in matrix form as
follows:
follows:
where
where M
M is the number of states to be memorised
is the number of states to be memorised
by the network,
by the network, Y
Ym
m is the
is the n
n-dimensional binary
-dimensional binary
vector,
vector, I
I is
is n
n 
 n
n identity matrix, and superscript
identity matrix, and superscript T
T
denotes a matrix transposition.
denotes a matrix transposition.
I
Y
Y
W M
M
m
T
m
m 


1

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 62
Possible states for the three-neuron
Possible states for the three-neuron
Hopfield network
Hopfield network
y1
y2
y3
(1,  1, 1)
( 1,  1, 1)
( 1,  1,  1) (1,  1,  1)
(1, 1, 1)
( 1, 1, 1)
(1, 1,  1)
( 1, 1,  1)
0

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 63
 The stable state-vertex is determined by the weight
The stable state-vertex is determined by the weight
matrix
matrix W
W, the current input vector
, the current input vector X
X, and the
, and the
threshold matrix
threshold matrix 
. If the input vector is partially
. If the input vector is partially
incorrect or incomplete, the initial state will converge
incorrect or incomplete, the initial state will converge
into the stable state-vertex after a few iterations.
into the stable state-vertex after a few iterations.
 Suppose, for instance, that our network is required to
Suppose, for instance, that our network is required to
memorise two opposite states, (1, 1, 1) and (
memorise two opposite states, (1, 1, 1) and (
1,
1, 
1,
1, 
1).
1).
Thus,
Thus,
or
or
where
where Y
Y1
1 and
and Y
Y2
2 are the three-dimensional vectors.
are the three-dimensional vectors.











1
1
1
1
Y














1
1
1
2
Y  
1
1
1
1 
T
Y  
1
1
1
2 



T
Y

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 64
 The 3
The 3 
 3 identity matrix
3 identity matrix I
I is
is
 Thus, we can now determine the weight matrix as
Thus, we can now determine the weight matrix as
follows:
follows:
 Next, the network is tested by the sequence of input
Next, the network is tested by the sequence of input
vectors,
vectors, X
X1
1 and
and X
X2
2, which are equal to the output (or
, which are equal to the output (or
target) vectors
target) vectors Y
Y1
1 and
and Y
Y2
2, respectively.
, respectively.











1
0
0
0
1
0
0
0
1
I
   







































1
0
0
0
1
0
0
0
1
2
1
1
1
1
1
1
1
1
1
1
1
1
W











0
2
2
2
0
2
2
2
0

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 65
 First, we activate the Hopfield network by applying
First, we activate the Hopfield network by applying
the input vector
the input vector X
X. Then, we calculate the actual
. Then, we calculate the actual
output vector
output vector Y
Y, and finally, we compare the result
, and finally, we compare the result
with the initial input vector
with the initial input vector X
X.
.





















































1
1
1
0
0
0
1
1
1
0
2
2
2
0
2
2
2
0
1 sign
Y



























































1
1
1
0
0
0
1
1
1
0
2
2
2
0
2
2
2
0
2 sign
Y

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 66
 The remaining six states are all unstable. However,
The remaining six states are all unstable. However,
stable states (also called
stable states (also called fundamental memories
fundamental memories) are
) are
capable of attracting states that are close to them.
capable of attracting states that are close to them.
 The fundamental memory (1, 1, 1) attracts unstable
The fundamental memory (1, 1, 1) attracts unstable
states (
states (
1, 1, 1), (1,
1, 1, 1), (1, 
1, 1) and (1, 1,
1, 1) and (1, 1, 
1). Each of these
1). Each of these
unstable states represents a single error, compared to
unstable states represents a single error, compared to
the fundamental memory (1, 1, 1).
the fundamental memory (1, 1, 1).
 The fundamental memory (
The fundamental memory (
1,
1, 
1,
1, 
1) attracts unstable
1) attracts unstable
states (
states (
1,
1, 
1, 1), (
1, 1), (
1, 1,
1, 1, 
1) and (1,
1) and (1, 
1,
1, 
1).
1).
 Thus, the Hopfield network can act as an
Thus, the Hopfield network can act as an error
error
correction network
correction network.
.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 67
 Storage capacity
Storage capacity is
is or the largest number of
or the largest number of
fundamental memories that can be stored and
fundamental memories that can be stored and
retrieved correctly.
retrieved correctly.
 The maximum number of fundamental memories
The maximum number of fundamental memories
M
Mmax
max that can be stored in the
that can be stored in the n
n-neuron recurrent
-neuron recurrent
network is limited by
network is limited by
n
Mmax 15
.
0

Storage capacity of the Hopfield network
Storage capacity of the Hopfield network

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 68
 The Hopfield network represents an
The Hopfield network represents an autoassociative
autoassociative
type of memory
type of memory 
 it can retrieve a corrupted or
it can retrieve a corrupted or
incomplete memory but cannot associate this memory
incomplete memory but cannot associate this memory
with another different memory.
with another different memory.
 Human memory is essentially
Human memory is essentially associative
associative. One thing
. One thing
may remind us of another, and that of another, and so
may remind us of another, and that of another, and so
on. We use a chain of mental associations to recover
on. We use a chain of mental associations to recover
a lost memory. If we forget where we left an
a lost memory. If we forget where we left an
umbrella, we try to recall where we last had it, what
umbrella, we try to recall where we last had it, what
we were doing, and who we were talking to. We
we were doing, and who we were talking to. We
attempt to establish a chain of associations, and
attempt to establish a chain of associations, and
thereby to restore a lost memory.
thereby to restore a lost memory.
Bidirectional associative memory (BAM)
Bidirectional associative memory (BAM)

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 69
 To associate one memory with another, we need a
To associate one memory with another, we need a
recurrent neural network capable of accepting an
recurrent neural network capable of accepting an
input pattern on one set of neurons and producing
input pattern on one set of neurons and producing
a related, but different, output pattern on another
a related, but different, output pattern on another
set of neurons.
set of neurons.
 Bidirectional associative memory
Bidirectional associative memory (BAM)
(BAM), first
, first
proposed by
proposed by Bart Kosko
Bart Kosko, is a heteroassociative
, is a heteroassociative
network. It associates patterns from one set, set
network. It associates patterns from one set, set A
A,
,
to patterns from another set, set
to patterns from another set, set B
B, and vice versa.
, and vice versa.
Like a Hopfield network, the BAM can generalise
Like a Hopfield network, the BAM can generalise
and also produce correct outputs despite corrupted
and also produce correct outputs despite corrupted
or incomplete inputs.
or incomplete inputs.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 70
BAM operation
BAM operation
yj(p)
y1(p)
y2(p)
ym(p)
1
2
j
m
Output
layer
Input
layer
xi(p)
x1(p)
x2(p)
xn(p)
2
i
n
1
xi(p+1)
x1(p+1)
x2(p+1)
xn(p+1)
yj(p)
y1(p)
y2(p)
ym(p)
1
2
j
m
Output
layer
Input
layer
2
i
n
1
(a) Forward direction. (b) Backward direction.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 71
The basic idea behind the BAM is to store
The basic idea behind the BAM is to store
pattern pairs so that when
pattern pairs so that when n
n-dimensional vector
-dimensional vector
X
X from set
from set A
A is presented as input, the BAM
is presented as input, the BAM
recalls
recalls m
m-dimensional vector
-dimensional vector Y
Y from set
from set B
B, but
, but
when
when Y
Y is presented as input, the BAM recalls
is presented as input, the BAM recalls
X
X.
.

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 72
 To develop the BAM, we need to create a
To develop the BAM, we need to create a
correlation matrix for each pattern pair we want to
correlation matrix for each pattern pair we want to
store. The correlation matrix is the matrix product
store. The correlation matrix is the matrix product
of the input vector
of the input vector X
X, and the transpose of the
, and the transpose of the
output vector
output vector Y
YT
T
. The BAM weight matrix is the
. The BAM weight matrix is the
sum of all correlation matrices, that is,
sum of all correlation matrices, that is,
where
where M
M is the number of pattern pairs to be stored
is the number of pattern pairs to be stored
in the BAM.
in the BAM.
T
m
M
m
m Y
X
W 


1

 Negnevitsky, Pearson Education, 2002
Negnevitsky, Pearson Education, 2002 73
 The BAM is
The BAM is unconditionally stable
unconditionally stable. This means that
. This means that
any set of associations can be learned without risk of
any set of associations can be learned without risk of
instability.
instability.
 The maximum number of associations to be stored
The maximum number of associations to be stored
in the BAM should not exceed the number of
in the BAM should not exceed the number of
neurons in the smaller layer.
neurons in the smaller layer.
 The more serious problem with the BAM is
The more serious problem with the BAM is
incorrect convergence
incorrect convergence. The BAM may not
. The BAM may not
always produce the closest association. In fact, a
always produce the closest association. In fact, a
stable association may be only slightly related to
stable association may be only slightly related to
the initial input vector.
the initial input vector.
Stability and storage capacity of the BAM
Stability and storage capacity of the BAM

neural network supervised learning for Al.ppt

  • 1.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 1 Lecture 7 Lecture 7 Artificial neural networks: Artificial neural networks: Supervised learning Supervised learning  Introduction, or how the brain works Introduction, or how the brain works  The neuron as a simple computing element The neuron as a simple computing element  The perceptron The perceptron  Multilayer neural networks Multilayer neural networks  Accelerated learning in multilayer neural networks Accelerated learning in multilayer neural networks  The Hopfield network The Hopfield network  Bidirectional associative memories (BAM) Bidirectional associative memories (BAM)  Summary Summary
  • 2.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 2 Introduction, or how the brain works Introduction, or how the brain works Machine learning involves adaptive mechanisms Machine learning involves adaptive mechanisms that enable computers to learn from experience, that enable computers to learn from experience, learn by example and learn by analogy. Learning learn by example and learn by analogy. Learning capabilities can improve the performance of an capabilities can improve the performance of an intelligent system over time. The most popular intelligent system over time. The most popular approaches to machine learning are approaches to machine learning are artificial artificial neural networks neural networks and and genetic algorithms genetic algorithms. This . This lecture is dedicated to neural networks. lecture is dedicated to neural networks.
  • 3.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 3  A A neural network neural network can be defined as a model of can be defined as a model of reasoning based on the human brain. The brain reasoning based on the human brain. The brain consists of a densely interconnected set of nerve consists of a densely interconnected set of nerve cells, or basic information-processing units, called cells, or basic information-processing units, called neurons neurons. .  The human brain incorporates nearly 10 billion The human brain incorporates nearly 10 billion neurons and 60 trillion connections, neurons and 60 trillion connections, synapses synapses, , between them. By using multiple neurons between them. By using multiple neurons simultaneously, the brain can perform its functions simultaneously, the brain can perform its functions much faster than the fastest computers in existence much faster than the fastest computers in existence today. today.
  • 4.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 4  Each neuron has a very simple structure, but an Each neuron has a very simple structure, but an army of such elements constitutes a tremendous army of such elements constitutes a tremendous processing power. processing power.  A neuron consists of a cell body, A neuron consists of a cell body, soma soma, a number of , a number of fibers called fibers called dendrites dendrites, and a single long fiber , and a single long fiber called the called the axon axon. .
  • 5.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 5 Biological neural network Biological neural network Soma Soma Synapse Synapse Dendrites Axon Synapse Dendrites Axon
  • 6.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 6  Our brain can be considered as a highly complex, Our brain can be considered as a highly complex, non-linear and parallel information-processing non-linear and parallel information-processing system. system.  Information is stored and processed in a neural Information is stored and processed in a neural network simultaneously throughout the whole network simultaneously throughout the whole network, rather than at specific locations. In other network, rather than at specific locations. In other words, in neural networks, both data and its words, in neural networks, both data and its processing are processing are global global rather than local. rather than local.  Learning is a fundamental and essential Learning is a fundamental and essential characteristic of biological neural networks. The characteristic of biological neural networks. The ease with which they can learn led to attempts to ease with which they can learn led to attempts to emulate a biological neural network in a computer. emulate a biological neural network in a computer.
  • 7.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 7  An artificial neural network consists of a number of An artificial neural network consists of a number of very simple processors, also called very simple processors, also called neurons neurons, which , which are analogous to the biological neurons in the brain. are analogous to the biological neurons in the brain.  The neurons are connected by weighted links The neurons are connected by weighted links passing signals from one neuron to another. passing signals from one neuron to another.  The output signal is transmitted through the The output signal is transmitted through the neuron’s outgoing connection. The outgoing neuron’s outgoing connection. The outgoing connection splits into a number of branches that connection splits into a number of branches that transmit the same signal. The outgoing branches transmit the same signal. The outgoing branches terminate at the incoming connections of other terminate at the incoming connections of other neurons in the network. neurons in the network.
  • 8.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 8 Architecture of a typical artificial neural network Architecture of a typical artificial neural network Input Layer Output Layer Middle Layer I n p u t S i g n a l s O u t p u t S i g n a l s
  • 9.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 9 Analogy between biological and Analogy between biological and artificial neural networks artificial neural networks
  • 10.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 10 The neuron as a simple computing element The neuron as a simple computing element Diagram of a neuron Diagram of a neuron Neuron Y Input Signals x1 x2 xn Output Signals Y Y Y w2 w1 wn Weights
  • 11.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 11  The neuron computes the weighted sum of the input The neuron computes the weighted sum of the input signals and compares the result with a signals and compares the result with a threshold threshold value value, ,  . If the net input is less than the threshold, . If the net input is less than the threshold, the neuron output is –1. But if the net input is greater the neuron output is –1. But if the net input is greater than or equal to the threshold, the neuron becomes than or equal to the threshold, the neuron becomes activated and its output attains a value +1. activated and its output attains a value +1.  The neuron uses the following transfer or The neuron uses the following transfer or activation activation function function: :  This type of activation function is called a This type of activation function is called a sign sign function function. .    n i i iw x X 1           X X Y if , 1 if , 1
  • 12.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 12 Activation functions of a neuron Activation functions of a neuron Step function Sign function +1 -1 0 +1 -1 0 X Y X Y +1 -1 0 X Y Sigm oid function +1 -1 0 X Y L inear function       0 if , 0 0 if , 1 X X Y step         0 if , 1 0 if , 1 X X Y sign X sigmoid e Y    1 1 X Y linear 
  • 13.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 13 Can a single neuron learn a task? Can a single neuron learn a task?  In 1958, In 1958, Frank Rosenblatt Frank Rosenblatt introduced a training introduced a training algorithm that provided the first procedure for algorithm that provided the first procedure for training a simple ANN: a training a simple ANN: a perceptron perceptron. .  The perceptron is the simplest form of a neural The perceptron is the simplest form of a neural network. It consists of a single neuron with network. It consists of a single neuron with adjustable adjustable synaptic weights and a synaptic weights and a hard limiter hard limiter. .
  • 14.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 14 T h r e s h o l d I n p u t s x 1 x 2 O u t p u t Y  H a r d L i m i t e r w 2 w 1 L i n e a r C o m b i n e r  Single-layer two-input perceptron Single-layer two-input perceptron
  • 15.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 15 The Perceptron The Perceptron  The operation of Rosenblatt’s perceptron is based The operation of Rosenblatt’s perceptron is based on the on the McCulloch and Pitts neuron model McCulloch and Pitts neuron model. The . The model consists of a linear combiner followed by a model consists of a linear combiner followed by a hard limiter. hard limiter.  The weighted sum of the inputs is applied to the The weighted sum of the inputs is applied to the hard limiter, which produces an output equal to +1 hard limiter, which produces an output equal to +1 if its input is positive and if its input is positive and  1 if it is negative. 1 if it is negative.
  • 16.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 16  The aim of the perceptron is to classify inputs, The aim of the perceptron is to classify inputs, x x1 1, , x x2 2, . . ., , . . ., x xn n, into one of two classes, say , into one of two classes, say A A1 1 and and A A2 2. .  In the case of an elementary perceptron, the n- In the case of an elementary perceptron, the n- dimensional space is divided by a dimensional space is divided by a hyperplane hyperplane into into two decision regions. The hyperplane is defined by two decision regions. The hyperplane is defined by the the linearly separable linearly separable function function: : 0 1      n i i iw x
  • 17.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 17 Linear separability in the perceptrons Linear separability in the perceptrons x1 x2 Class A2 Class A1 1 2 x1w1 + x2w2   = 0 (a) Two-input perceptron. (b) Three-input perceptron. x2 x1 x3 x1w1 + x2w2 + x3w3   = 0 1 2
  • 18.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 18 This is done by making small adjustments in the This is done by making small adjustments in the weights to reduce the difference between the actual weights to reduce the difference between the actual and desired outputs of the perceptron. The initial and desired outputs of the perceptron. The initial weights are randomly assigned, usually in the range weights are randomly assigned, usually in the range [ [ 0.5, 0.5], and then updated to obtain the output 0.5, 0.5], and then updated to obtain the output consistent with the training examples. consistent with the training examples. How does the perceptron learn its classification How does the perceptron learn its classification tasks? tasks?
  • 19.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 19  If at iteration If at iteration p p, the actual output is , the actual output is Y Y( (p p) and the ) and the desired output is desired output is Y Yd d ( (p p), then the error is given by: ), then the error is given by: where where p p = 1, 2, 3, . . . = 1, 2, 3, . . . Iteration Iteration p p here refers to the here refers to the p pth training example th training example presented to the perceptron. presented to the perceptron.  If the error, If the error, e e( (p p), is positive, we need to increase ), is positive, we need to increase perceptron output perceptron output Y Y( (p p), but if it is negative, we ), but if it is negative, we need to decrease need to decrease Y Y( (p p). ). ) ( ) ( ) ( p Y p Y p e d  
  • 20.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 20 The perceptron learning rule The perceptron learning rule where where p p = 1, 2, 3, . . . = 1, 2, 3, . . .   is the is the learning rate learning rate, a positive constant less than , a positive constant less than unity. unity. The perceptron learning rule was first proposed by The perceptron learning rule was first proposed by Rosenblatt Rosenblatt in 1960. Using this rule we can derive in 1960. Using this rule we can derive the perceptron training algorithm for classification the perceptron training algorithm for classification tasks. tasks. ) ( ) ( ) ( ) 1 ( p e p x p w p w i i i      
  • 21.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 21 Step 1 Step 1: Initialisation : Initialisation Set initial weights Set initial weights w w1 1, , w w2 2,…, ,…, w wn n and threshold and threshold   to random numbers in the range [ to random numbers in the range [ 0.5, 0.5]. 0.5, 0.5]. If the error, If the error, e e( (p p), is positive, we need to increase ), is positive, we need to increase perceptron output perceptron output Y Y( (p p), but if it is negative, we ), but if it is negative, we need to decrease need to decrease Y Y( (p p). ). Perceptron’s training algorithm Perceptron’s training algorithm
  • 22.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 22 Step 2 Step 2: Activation : Activation Activate the perceptron by applying inputs Activate the perceptron by applying inputs x x1 1( (p p), ), x x2 2( (p p),…, ),…, x xn n( (p p) and desired output ) and desired output Y Yd d ( (p p). ). Calculate the actual output at iteration Calculate the actual output at iteration p p = 1 = 1 where where n n is the number of the perceptron inputs, is the number of the perceptron inputs, and and step step is a step activation function. is a step activation function. Perceptron’s training algorithm (continued) Perceptron’s training algorithm (continued)              n i i i p w p x step p Y 1 ) ( ) ( ) (
  • 23.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 23 Step 3 Step 3: Weight training : Weight training Update the weights of the perceptron Update the weights of the perceptron where where  w wi i( (p p) is the weight correction at iteration ) is the weight correction at iteration p p. . The weight correction is computed by the The weight correction is computed by the delta delta rule rule: : Step 4 Step 4: Iteration : Iteration Increase iteration Increase iteration p p by one, go back to by one, go back to Step 2 Step 2 and and repeat the process until convergence. repeat the process until convergence. ) ( ) ( ) 1 ( p w p w p w i i i     Perceptron’s training algorithm (continued) Perceptron’s training algorithm (continued) ) ( ) ( ) ( p e p x p w i i     
  • 24.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 24 Example of perceptron learning: the logical operation Example of perceptron learning: the logical operation AND AND Inputs x1 x2 0 0 1 1 0 1 0 1 0 0 0 Epoch Desired output Yd 1 Initial weights w1 w2 1 0.3 0.3 0.3 0.2  0.1  0.1  0.1  0.1 0 0 1 0 Actual output Y Error e 0 0  1 1 Final weights w1 w2 0.3 0.3 0.2 0.3  0.1  0.1  0.1 0.0 0 0 1 1 0 1 0 1 0 0 0 2 1 0.3 0.3 0.3 0.2 0 0 1 1 0 0  1 0 0.3 0.3 0.2 0.2 0.0 0.0 0.0 0.0 0 0 1 1 0 1 0 1 0 0 0 3 1 0.2 0.2 0.2 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 1 0 0 0  1 1 0.2 0.2 0.1 0.2 0.0 0.0 0.0 0.1 0 0 1 1 0 1 0 1 0 0 0 4 1 0.2 0.2 0.2 0.1 0.1 0.1 0.1 0.1 0 0 1 1 0 0  1 0 0.2 0.2 0.1 0.1 0.1 0.1 0.1 0.1 0 0 1 1 0 1 0 1 0 0 0 5 1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0 0 0 1 0 0 0 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0 Threshold:  = 0.2; learning rate:  = 0.1
  • 25.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 25 Two-dimensional plots of basic logical operations Two-dimensional plots of basic logical operations x1 x2 1 (a) AND (x1  x2) 1 x1 x2 1 1 (b) OR (x1  x2) x1 x2 1 1 (c) Exclusive-OR (x1  x2) 0 0 0 A perceptron can learn the operations A perceptron can learn the operations AND AND and and OR OR, , but not but not Exclusive-OR Exclusive-OR. .
  • 26.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 26 Multilayer neural networks Multilayer neural networks  A multilayer perceptron is a feedforward neural A multilayer perceptron is a feedforward neural network with one or more hidden layers. network with one or more hidden layers.  The network consists of an The network consists of an input layer input layer of source of source neurons, at least one middle or neurons, at least one middle or hidden layer hidden layer of of computational neurons, and an computational neurons, and an output layer output layer of of computational neurons. computational neurons.  The input signals are propagated in a forward The input signals are propagated in a forward direction on a layer-by-layer basis. direction on a layer-by-layer basis.
  • 27.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 27 Multilayer perceptron with two hidden layers Multilayer perceptron with two hidden layers Input layer First hidden layer Second hidden layer Output layer O u t p u t S i g n a l s I n p u t S i g n a l s
  • 28.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 28 What does the middle layer hide? What does the middle layer hide?  A hidden layer “hides” its desired output. A hidden layer “hides” its desired output. Neurons in the hidden layer cannot be observed Neurons in the hidden layer cannot be observed through the input/output behaviour of the network. through the input/output behaviour of the network. There is no obvious way to know what the desired There is no obvious way to know what the desired output of the hidden layer should be. output of the hidden layer should be.  Commercial ANNs incorporate three and Commercial ANNs incorporate three and sometimes four layers, including one or two sometimes four layers, including one or two hidden layers. Each layer can contain from 10 to hidden layers. Each layer can contain from 10 to 1000 neurons. Experimental neural networks may 1000 neurons. Experimental neural networks may have five or even six layers, including three or have five or even six layers, including three or four hidden layers, and utilise millions of neurons. four hidden layers, and utilise millions of neurons.
  • 29.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 29 Back-propagation neural network Back-propagation neural network  Learning in a multilayer network proceeds the Learning in a multilayer network proceeds the same way as for a perceptron. same way as for a perceptron.  A training set of input patterns is presented to the A training set of input patterns is presented to the network. network.  The network computes its output pattern, and if The network computes its output pattern, and if there is an error there is an error   or in other words a difference or in other words a difference between actual and desired output patterns between actual and desired output patterns   the the weights are adjusted to reduce this error. weights are adjusted to reduce this error.
  • 30.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 30  In a back-propagation neural network, the learning In a back-propagation neural network, the learning algorithm has two phases. algorithm has two phases.  First, a training input pattern is presented to the First, a training input pattern is presented to the network input layer. The network propagates the network input layer. The network propagates the input pattern from layer to layer until the output input pattern from layer to layer until the output pattern is generated by the output layer. pattern is generated by the output layer.  If this pattern is different from the desired output, If this pattern is different from the desired output, an error is calculated and then propagated an error is calculated and then propagated backwards through the network from the output backwards through the network from the output layer to the input layer. The weights are modified layer to the input layer. The weights are modified as the error is propagated. as the error is propagated.
  • 31.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 31 Three-layer back-propagation neural network Three-layer back-propagation neural network Input layer xi x1 x2 xn 1 2 i n Output layer 1 2 k l yk y1 y2 yl Input signals Error signals wjk Hidden layer wij 1 2 j m
  • 32.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 32 Step 1 Step 1: Initialisation : Initialisation Set all the weights and threshold levels of the Set all the weights and threshold levels of the network to random numbers uniformly network to random numbers uniformly distributed inside a small range: distributed inside a small range: where where F Fi i is the total number of inputs of neuron is the total number of inputs of neuron i i in the network. The weight initialisation is done in the network. The weight initialisation is done on a neuron-by-neuron basis. on a neuron-by-neuron basis. The back-propagation training algorithm The back-propagation training algorithm           i i F F 4 . 2 , 4 . 2
  • 33.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 33 Step 2 Step 2: Activation : Activation Activate the back-propagation neural network by Activate the back-propagation neural network by applying inputs applying inputs x x1 1( (p p), ), x x2 2( (p p),…, ),…, x xn n( (p p) and desired ) and desired outputs outputs y yd d,1 ,1( (p p), ), y yd d,2 ,2( (p p),…, ),…, y yd d, ,n n( (p p). ). ( (a a) Calculate the actual outputs of the neurons in ) Calculate the actual outputs of the neurons in the hidden layer: the hidden layer: where where n n is the number of inputs of neuron is the number of inputs of neuron j j in the in the hidden layer, and hidden layer, and sigmoid sigmoid is the is the sigmoid sigmoid activation activation function. function.               j n i ij i j p w p x sigmoid p y 1 ) ( ) ( ) (
  • 34.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 34 ( (b b) Calculate the actual outputs of the neurons in ) Calculate the actual outputs of the neurons in the output layer: the output layer: where where m m is the number of inputs of neuron is the number of inputs of neuron k k in the in the output layer. output layer.               k m j jk jk k p w p x sigmoid p y 1 ) ( ) ( ) ( Step 2 Step 2: Activation (continued) : Activation (continued)
  • 35.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 35 Step 3 Step 3: Weight training : Weight training Update the weights in the back-propagation network Update the weights in the back-propagation network propagating backward the errors associated with propagating backward the errors associated with output neurons. output neurons. ( (a a) Calculate the error gradient for the neurons in the ) Calculate the error gradient for the neurons in the output layer: output layer: where where Calculate the weight corrections: Calculate the weight corrections: Update the weights at the output neurons: Update the weights at the output neurons:   ) ( ) ( 1 ) ( ) ( p e p y p y p k k k k      ) ( ) ( ) ( , p y p y p e k k d k   ) ( ) ( ) ( p p y p w k j jk       ) ( ) ( ) 1 ( p w p w p w jk jk jk    
  • 36.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 36 ( (b b) Calculate the error gradient for the neurons in ) Calculate the error gradient for the neurons in the hidden layer: the hidden layer: Calculate the weight corrections: Calculate the weight corrections: Update the weights at the hidden neurons: Update the weights at the hidden neurons: ) ( ) ( ) ( 1 ) ( ) ( 1 ] [ p w p p y p y p jk l k k j j j         ) ( ) ( ) ( p p x p w j i ij       ) ( ) ( ) 1 ( p w p w p w ij ij ij     Step 3 Step 3: Weight training (continued) : Weight training (continued)
  • 37.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 37 Step 4 Step 4: Iteration : Iteration Increase iteration Increase iteration p p by one, go back to by one, go back to Step 2 Step 2 and and repeat the process until the selected error criterion repeat the process until the selected error criterion is satisfied. is satisfied. As an example, we may consider the three-layer As an example, we may consider the three-layer back-propagation network. Suppose that the back-propagation network. Suppose that the network is required to perform logical operation network is required to perform logical operation Exclusive-OR Exclusive-OR. Recall that a single-layer perceptron . Recall that a single-layer perceptron could not do this operation. Now we will apply the could not do this operation. Now we will apply the three-layer net. three-layer net.
  • 38.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 38 Three-layer network for solving the Three-layer network for solving the Exclusive-OR operation Exclusive-OR operation y5 5 x1 3 1 x2 Input layer Output layer Hidden layer 4 2  3 w13 w24 w23 w24 w35 w45  4  5  1  1  1
  • 39.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 39  The effect of the threshold applied to a neuron in the The effect of the threshold applied to a neuron in the hidden or output layer is represented by its weight, hidden or output layer is represented by its weight,  , , connected to a fixed input equal to connected to a fixed input equal to  1. 1.  The initial weights and threshold levels are set The initial weights and threshold levels are set randomly as follows: randomly as follows: w w13 13 = 0.5, = 0.5, w w14 14 = 0.9, = 0.9, w w23 23 = 0.4, = 0.4, w w24 24 = 1.0, = 1.0, w w35 35 = =  1.2, 1.2, w w45 45 = 1.1, = 1.1,  3 3 = 0.8, = 0.8,  4 4 = =  0.1 and 0.1 and  5 5 = 0.3. = 0.3.
  • 40.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 40  We consider a training set where inputs We consider a training set where inputs x x1 1 and and x x2 2 are are equal to 1 and desired output equal to 1 and desired output y yd d,5 ,5 is 0. The actual is 0. The actual outputs of neurons 3 and 4 in the hidden layer are outputs of neurons 3 and 4 in the hidden layer are calculated as calculated as   5250 . 0 1 / 1 ) ( ) 8 . 0 1 4 . 0 1 5 . 0 1 ( 3 23 2 13 1 3              e w x w x sigmoid y   8808 . 0 1 / 1 ) ( ) 1 . 0 1 0 . 1 1 9 . 0 1 ( 4 24 2 14 1 4              e w x w x sigmoid y  Now the actual output of neuron 5 in the output layer Now the actual output of neuron 5 in the output layer is determined as: is determined as:  Thus, the following error is obtained: Thus, the following error is obtained:   5097 . 0 1 / 1 ) ( ) 3 . 0 1 1 . 1 8808 . 0 2 . 1 5250 . 0 ( 5 45 4 35 3 5               e w y w y sigmoid y 5097 . 0 5097 . 0 0 5 5 ,       y y e d
  • 41.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 41  The next step is weight training. To update the The next step is weight training. To update the weights and threshold levels in our network, we weights and threshold levels in our network, we propagate the error, propagate the error, e e, from the output layer , from the output layer backward to the input layer. backward to the input layer.  First, we calculate the error gradient for neuron 5 in First, we calculate the error gradient for neuron 5 in the output layer: the output layer: 1274 . 0 5097) . 0 ( 0.5097) (1 0.5097 ) 1 ( 5 5 5          e y y   Then we determine the weight corrections assuming Then we determine the weight corrections assuming that the learning rate parameter, that the learning rate parameter,  , is equal to 0.1: , is equal to 0.1: 0112 . 0 ) 1274 . 0 ( 8808 . 0 1 . 0 5 4 45             y w 0067 . 0 ) 1274 . 0 ( 5250 . 0 1 . 0 5 3 35             y w 0127 . 0 ) 1274 . 0 ( ) 1 ( 1 . 0 ) 1 ( 5 5               
  • 42.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 42  Next we calculate the error gradients for neurons 3 Next we calculate the error gradients for neurons 3 and 4 in the hidden layer: and 4 in the hidden layer:  We then determine the weight corrections: We then determine the weight corrections: 0381 . 0 ) 2 . 1 ( 0.1274) ( 0.5250) (1 0.5250 ) 1 ( 35 5 3 3 3             w y y   0.0147 .1 1 4) 0.127 ( 0.8808) (1 0.8808 ) 1 ( 45 5 4 4 4             w y y   0038 . 0 0381 . 0 1 1 . 0 3 1 13           x w 0038 . 0 0381 . 0 1 1 . 0 3 2 23           x w 0038 . 0 0381 . 0 ) 1 ( 1 . 0 ) 1 ( 3 3               0015 . 0 ) 0147 . 0 ( 1 1 . 0 4 1 14             x w 0015 . 0 ) 0147 . 0 ( 1 1 . 0 4 2 24             x w 0015 . 0 ) 0147 . 0 ( ) 1 ( 1 . 0 ) 1 ( 4 4              
  • 43.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 43  At last, we update all weights and threshold: At last, we update all weights and threshold: 5038 . 0 0038 . 0 5 . 0 13 13 13       w w w 8985 . 0 0015 . 0 9 . 0 14 14 14       w w w 4038 . 0 0038 . 0 4 . 0 23 23 23       w w w 9985 . 0 0015 . 0 0 . 1 24 24 24       w w w 2067 . 1 0067 . 0 2 . 1 35 35 35         w w w 0888 . 1 0112 . 0 1 . 1 45 45 45       w w w 7962 . 0 0038 . 0 8 . 0 3 3 3          0985 . 0 0015 . 0 1 . 0 4 4 4            3127 . 0 0127 . 0 3 . 0 5 5 5           The training process is repeated until the sum of The training process is repeated until the sum of squared errors is less than 0.001. squared errors is less than 0.001.
  • 44.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 44 Learning curve for operation Learning curve for operation Exclusive-OR Exclusive-OR 0 50 100 150 200 101 Epoch Sum-Squared Error Sum-Squared Network Error for 224 Epochs 100 10-1 10-2 10-3 10-4
  • 45.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 45 Final results of three-layer network learning Final results of three-layer network learning Inputs x1 x2 1 0 1 0 1 1 0 0 0 1 1 Desired output yd 0 0.0155 Actual output y5 Y Error e Sum of squared errors e 0.9849 0.9849 0.0175  0.0155 0.0151 0.0151  0.0175 0.0010
  • 46.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 46 Network represented by McCulloch-Pitts model Network represented by McCulloch-Pitts model for solving the for solving the Exclusive-OR Exclusive-OR operation operation y5 5 x1 3 1 x2 4 2 +1.0  1  1  1 +1.0 +1.0 +1.0 +1.5 +1.0 +0.5 +0.5  2.0
  • 47.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 47 ( (a a) Decision boundary constructed by hidden neuron 3; ) Decision boundary constructed by hidden neuron 3; ( (b b) Decision boundary constructed by hidden neuron 4; ) Decision boundary constructed by hidden neuron 4; ( (c c) Decision boundaries constructed by the complete ) Decision boundaries constructed by the complete three-layer network three-layer network x1 x2 1 (a) 1 x2 1 1 (b) 0 0 x1 + x2 – 1.5 = 0 x1 + x2 – 0.5 = 0 x1 x1 x2 1 1 (c) 0 Decision boundaries Decision boundaries
  • 48.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 48 Accelerated learning in multilayer Accelerated learning in multilayer neural networks neural networks  A multilayer network learns much faster when the A multilayer network learns much faster when the sigmoidal activation function is represented by a sigmoidal activation function is represented by a hyperbolic tangent hyperbolic tangent: : where where a a and and b b are constants. are constants. Suitable values for Suitable values for a a and and b b are: are: a a = 1.716 and = 1.716 and b b = 0.667 = 0.667 a e a Y bX h tan     1 2
  • 49.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 49  We also can accelerate training by including a We also can accelerate training by including a momentum term momentum term in the delta rule: in the delta rule: where where   is a positive number (0 is a positive number (0       1) called the 1) called the momentum constant momentum constant. Typically, the momentum . Typically, the momentum constant is set to 0.95. constant is set to 0.95. This equation is called the This equation is called the generalised delta rule generalised delta rule. . ) ( ) ( ) 1 ( ) ( p p y p w p w k j jk jk           
  • 50.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 50 Learning with momentum for operation Learning with momentum for operation Exclusive-OR Exclusive-OR 0 20 40 60 80 100 120 10-4 10-2 100 102 Epoch Sum-Squared Error Training for 126 Epochs 0 100 140 -1 -0.5 0 0.5 1 1.5 Epoch Learning Rate 10-3 101 10-1 20 40 60 80 120
  • 51.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 51 Learning with adaptive learning rate Learning with adaptive learning rate To accelerate the convergence and yet avoid the To accelerate the convergence and yet avoid the danger of instability, we can apply two heuristics: danger of instability, we can apply two heuristics: Heuristic 1 Heuristic 1 If the change of the sum of squared errors has the same If the change of the sum of squared errors has the same algebraic sign for several consequent epochs, then the algebraic sign for several consequent epochs, then the learning rate parameter, learning rate parameter,  , should be increased. , should be increased. Heuristic 2 Heuristic 2 If the algebraic sign of the change of the sum of If the algebraic sign of the change of the sum of squared errors alternates for several consequent squared errors alternates for several consequent epochs, then the learning rate parameter, epochs, then the learning rate parameter,  , should be , should be decreased. decreased.
  • 52.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 52  Adapting the learning rate requires some changes Adapting the learning rate requires some changes in the back-propagation algorithm. in the back-propagation algorithm.  If the sum of squared errors at the current epoch If the sum of squared errors at the current epoch exceeds the previous value by more than a exceeds the previous value by more than a predefined ratio (typically 1.04), the learning rate predefined ratio (typically 1.04), the learning rate parameter is decreased (typically by multiplying parameter is decreased (typically by multiplying by 0.7) and new weights and thresholds are by 0.7) and new weights and thresholds are calculated. calculated.  If the error is less than the previous one, the If the error is less than the previous one, the learning rate is increased (typically by multiplying learning rate is increased (typically by multiplying by 1.05). by 1.05).
  • 53.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 53 Learning with adaptive learning rate Learning with adaptive learning rate 0 10 20 30 40 50 60 70 80 90 100 Epoch Training for 103 Epochs 0 20 40 60 80 100 120 0 0.2 0.4 0.6 0.8 1 Epoch Learning Rate 10-4 10-2 100 102 Sum-Squared Error 10-3 101 10-1
  • 54.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 54 Learning with momentum and adaptive learning rate Learning with momentum and adaptive learning rate 0 10 20 30 40 50 60 70 80 Epoch Training for 85 Epochs 0 10 20 30 40 50 60 70 80 90 0 0.5 1 2.5 Epoch Learning Rate 10-4 10-2 100 102 Sum-Squared Error 10-3 101 10-1 1.5 2
  • 55.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 55  Neural networks were designed on analogy with Neural networks were designed on analogy with the brain. The brain’s memory, however, works the brain. The brain’s memory, however, works by association. For example, we can recognise a by association. For example, we can recognise a familiar face even in an unfamiliar environment familiar face even in an unfamiliar environment within 100-200 ms. We can also recall a within 100-200 ms. We can also recall a complete sensory experience, including sounds complete sensory experience, including sounds and scenes, when we hear only a few bars of and scenes, when we hear only a few bars of music. The brain routinely associates one thing music. The brain routinely associates one thing with another. with another. The Hopfield Network The Hopfield Network
  • 56.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 56  Multilayer neural networks trained with the back- Multilayer neural networks trained with the back- propagation algorithm are used for pattern propagation algorithm are used for pattern recognition problems. However, to emulate the recognition problems. However, to emulate the human memory’s associative characteristics we human memory’s associative characteristics we need a different type of network: a need a different type of network: a recurrent recurrent neural network neural network. .  A recurrent neural network has feedback loops A recurrent neural network has feedback loops from its outputs to its inputs. The presence of from its outputs to its inputs. The presence of such loops has a profound impact on the learning such loops has a profound impact on the learning capability of the network. capability of the network.
  • 57.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 57  The stability of recurrent networks intrigued The stability of recurrent networks intrigued several researchers in the 1960s and 1970s. several researchers in the 1960s and 1970s. However, none was able to predict which network However, none was able to predict which network would be stable, and some researchers were would be stable, and some researchers were pessimistic about finding a solution at all. The pessimistic about finding a solution at all. The problem was solved only in 1982, when problem was solved only in 1982, when John John Hopfield Hopfield formulated the physical principle of formulated the physical principle of storing information in a dynamically stable storing information in a dynamically stable network. network.
  • 58.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 58 Single-layer Single-layer n n-neuron Hopfield network -neuron Hopfield network xi x1 x2 xn I n p u t S i g n a l s yi y1 y2 yn 1 2 i n O u t p u t S i g n a l s
  • 59.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 59  The Hopfield network uses McCulloch and Pitts The Hopfield network uses McCulloch and Pitts neurons with the neurons with the sign activation function sign activation function as its as its computing element: computing element:              X Y X X Y sign if , if , 1 0 if , 1
  • 60.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 60  The current state of the Hopfield network is The current state of the Hopfield network is determined by the current outputs of all neurons, determined by the current outputs of all neurons, y y1 1, , y y2 2, . . ., , . . ., y yn n. . Thus, for a single-layer Thus, for a single-layer n n-neuron network, the state -neuron network, the state can be defined by the can be defined by the state vector state vector as: as:                n y y y  2 1 Y
  • 61.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 61  In the Hopfield network, synaptic weights between In the Hopfield network, synaptic weights between neurons are usually represented in matrix form as neurons are usually represented in matrix form as follows: follows: where where M M is the number of states to be memorised is the number of states to be memorised by the network, by the network, Y Ym m is the is the n n-dimensional binary -dimensional binary vector, vector, I I is is n n   n n identity matrix, and superscript identity matrix, and superscript T T denotes a matrix transposition. denotes a matrix transposition. I Y Y W M M m T m m    1
  • 62.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 62 Possible states for the three-neuron Possible states for the three-neuron Hopfield network Hopfield network y1 y2 y3 (1,  1, 1) ( 1,  1, 1) ( 1,  1,  1) (1,  1,  1) (1, 1, 1) ( 1, 1, 1) (1, 1,  1) ( 1, 1,  1) 0
  • 63.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 63  The stable state-vertex is determined by the weight The stable state-vertex is determined by the weight matrix matrix W W, the current input vector , the current input vector X X, and the , and the threshold matrix threshold matrix  . If the input vector is partially . If the input vector is partially incorrect or incomplete, the initial state will converge incorrect or incomplete, the initial state will converge into the stable state-vertex after a few iterations. into the stable state-vertex after a few iterations.  Suppose, for instance, that our network is required to Suppose, for instance, that our network is required to memorise two opposite states, (1, 1, 1) and ( memorise two opposite states, (1, 1, 1) and ( 1, 1,  1, 1,  1). 1). Thus, Thus, or or where where Y Y1 1 and and Y Y2 2 are the three-dimensional vectors. are the three-dimensional vectors.            1 1 1 1 Y               1 1 1 2 Y   1 1 1 1  T Y   1 1 1 2     T Y
  • 64.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 64  The 3 The 3   3 identity matrix 3 identity matrix I I is is  Thus, we can now determine the weight matrix as Thus, we can now determine the weight matrix as follows: follows:  Next, the network is tested by the sequence of input Next, the network is tested by the sequence of input vectors, vectors, X X1 1 and and X X2 2, which are equal to the output (or , which are equal to the output (or target) vectors target) vectors Y Y1 1 and and Y Y2 2, respectively. , respectively.            1 0 0 0 1 0 0 0 1 I                                            1 0 0 0 1 0 0 0 1 2 1 1 1 1 1 1 1 1 1 1 1 1 W            0 2 2 2 0 2 2 2 0
  • 65.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 65  First, we activate the Hopfield network by applying First, we activate the Hopfield network by applying the input vector the input vector X X. Then, we calculate the actual . Then, we calculate the actual output vector output vector Y Y, and finally, we compare the result , and finally, we compare the result with the initial input vector with the initial input vector X X. .                                                      1 1 1 0 0 0 1 1 1 0 2 2 2 0 2 2 2 0 1 sign Y                                                            1 1 1 0 0 0 1 1 1 0 2 2 2 0 2 2 2 0 2 sign Y
  • 66.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 66  The remaining six states are all unstable. However, The remaining six states are all unstable. However, stable states (also called stable states (also called fundamental memories fundamental memories) are ) are capable of attracting states that are close to them. capable of attracting states that are close to them.  The fundamental memory (1, 1, 1) attracts unstable The fundamental memory (1, 1, 1) attracts unstable states ( states ( 1, 1, 1), (1, 1, 1, 1), (1,  1, 1) and (1, 1, 1, 1) and (1, 1,  1). Each of these 1). Each of these unstable states represents a single error, compared to unstable states represents a single error, compared to the fundamental memory (1, 1, 1). the fundamental memory (1, 1, 1).  The fundamental memory ( The fundamental memory ( 1, 1,  1, 1,  1) attracts unstable 1) attracts unstable states ( states ( 1, 1,  1, 1), ( 1, 1), ( 1, 1, 1, 1,  1) and (1, 1) and (1,  1, 1,  1). 1).  Thus, the Hopfield network can act as an Thus, the Hopfield network can act as an error error correction network correction network. .
  • 67.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 67  Storage capacity Storage capacity is is or the largest number of or the largest number of fundamental memories that can be stored and fundamental memories that can be stored and retrieved correctly. retrieved correctly.  The maximum number of fundamental memories The maximum number of fundamental memories M Mmax max that can be stored in the that can be stored in the n n-neuron recurrent -neuron recurrent network is limited by network is limited by n Mmax 15 . 0  Storage capacity of the Hopfield network Storage capacity of the Hopfield network
  • 68.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 68  The Hopfield network represents an The Hopfield network represents an autoassociative autoassociative type of memory type of memory   it can retrieve a corrupted or it can retrieve a corrupted or incomplete memory but cannot associate this memory incomplete memory but cannot associate this memory with another different memory. with another different memory.  Human memory is essentially Human memory is essentially associative associative. One thing . One thing may remind us of another, and that of another, and so may remind us of another, and that of another, and so on. We use a chain of mental associations to recover on. We use a chain of mental associations to recover a lost memory. If we forget where we left an a lost memory. If we forget where we left an umbrella, we try to recall where we last had it, what umbrella, we try to recall where we last had it, what we were doing, and who we were talking to. We we were doing, and who we were talking to. We attempt to establish a chain of associations, and attempt to establish a chain of associations, and thereby to restore a lost memory. thereby to restore a lost memory. Bidirectional associative memory (BAM) Bidirectional associative memory (BAM)
  • 69.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 69  To associate one memory with another, we need a To associate one memory with another, we need a recurrent neural network capable of accepting an recurrent neural network capable of accepting an input pattern on one set of neurons and producing input pattern on one set of neurons and producing a related, but different, output pattern on another a related, but different, output pattern on another set of neurons. set of neurons.  Bidirectional associative memory Bidirectional associative memory (BAM) (BAM), first , first proposed by proposed by Bart Kosko Bart Kosko, is a heteroassociative , is a heteroassociative network. It associates patterns from one set, set network. It associates patterns from one set, set A A, , to patterns from another set, set to patterns from another set, set B B, and vice versa. , and vice versa. Like a Hopfield network, the BAM can generalise Like a Hopfield network, the BAM can generalise and also produce correct outputs despite corrupted and also produce correct outputs despite corrupted or incomplete inputs. or incomplete inputs.
  • 70.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 70 BAM operation BAM operation yj(p) y1(p) y2(p) ym(p) 1 2 j m Output layer Input layer xi(p) x1(p) x2(p) xn(p) 2 i n 1 xi(p+1) x1(p+1) x2(p+1) xn(p+1) yj(p) y1(p) y2(p) ym(p) 1 2 j m Output layer Input layer 2 i n 1 (a) Forward direction. (b) Backward direction.
  • 71.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 71 The basic idea behind the BAM is to store The basic idea behind the BAM is to store pattern pairs so that when pattern pairs so that when n n-dimensional vector -dimensional vector X X from set from set A A is presented as input, the BAM is presented as input, the BAM recalls recalls m m-dimensional vector -dimensional vector Y Y from set from set B B, but , but when when Y Y is presented as input, the BAM recalls is presented as input, the BAM recalls X X. .
  • 72.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 72  To develop the BAM, we need to create a To develop the BAM, we need to create a correlation matrix for each pattern pair we want to correlation matrix for each pattern pair we want to store. The correlation matrix is the matrix product store. The correlation matrix is the matrix product of the input vector of the input vector X X, and the transpose of the , and the transpose of the output vector output vector Y YT T . The BAM weight matrix is the . The BAM weight matrix is the sum of all correlation matrices, that is, sum of all correlation matrices, that is, where where M M is the number of pattern pairs to be stored is the number of pattern pairs to be stored in the BAM. in the BAM. T m M m m Y X W    1
  • 73.
      Negnevitsky, PearsonEducation, 2002 Negnevitsky, Pearson Education, 2002 73  The BAM is The BAM is unconditionally stable unconditionally stable. This means that . This means that any set of associations can be learned without risk of any set of associations can be learned without risk of instability. instability.  The maximum number of associations to be stored The maximum number of associations to be stored in the BAM should not exceed the number of in the BAM should not exceed the number of neurons in the smaller layer. neurons in the smaller layer.  The more serious problem with the BAM is The more serious problem with the BAM is incorrect convergence incorrect convergence. The BAM may not . The BAM may not always produce the closest association. In fact, a always produce the closest association. In fact, a stable association may be only slightly related to stable association may be only slightly related to the initial input vector. the initial input vector. Stability and storage capacity of the BAM Stability and storage capacity of the BAM