74
Lecture 7 Lecture 7 Artificial neural networks: Artificial neural networks: Supervised learning Supervised learning 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 neuron as a simple computing element The neuron as a simple computing element The perceptron The perceptron M l il l k M l il l k 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) 11/14/2010 Intelligent Systems and Soft Computing 1 Summary Summary

Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

  • Upload
    others

  • View
    14

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Lecture 7 Lecture 7 Artificial neural networks: Artificial neural networks: Supervised learningSupervised learningSupervised learningSupervised learning Introduction, or how the brain worksIntroduction, or how the brain works The neuron as a simple computing elementThe neuron as a simple computing element The neuron as a simple computing elementThe neuron as a simple computing element The perceptronThe perceptronM l il l kM l il l kMultilayer neural networksMultilayer neural networks Accelerated learning in multilayer neural networksAccelerated learning in multilayer neural networks The Hopfield networkThe Hopfield network Bidirectional associative memories (BAM)Bidirectional associative memories (BAM)

11/14/2010 Intelligent Systems and Soft Computing 1

( )( ) SummarySummary

Page 2: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Introduction, or how the brain worksIntroduction, or how the brain works

Machine learning involves adaptive mechanisms Machine learning involves adaptive mechanisms that enable computers to learn from experiencethat enable computers to learn from experiencethat 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 ancapabilities can improve the performance of ancapabilities 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 areapproaches to machine learning are artificialartificialapproaches to machine learning are approaches to machine learning are artificial artificial neural networks neural networks and and genetic algorithmsgenetic algorithms. This . This lecture is dedicated to neural networks.lecture is dedicated to neural networks.

11/14/2010 Intelligent Systems and Soft Computing 2

Page 3: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

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 informationcells, or basic information--processing units, called processing units, called neuronsneurons..

The human brain incorporates nearly 10 billion The human brain incorporates nearly 10 billion neurons and 60 trillion connections, neurons and 60 trillion connections, synapsessynapses, , ,, y py p ,,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.

11/14/2010 Intelligent Systems and Soft Computing 3

Page 4: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Each neuron has a very simple structure, but an Each neuron has a very simple structure, but an y p ,y p ,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, somasoma, a number , a number of fibers calledof fibers called dendritesdendrites and a single long fiberand a single long fiberof fibers called of fibers called dendritesdendrites, and a single long fiber , and a single long fiber called the called the axonaxon..

11/14/2010 Intelligent Systems and Soft Computing 4

Page 5: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Biological neural networkBiological neural network

Synapse

SynapseAxon

DendritesAxon

SSoma SomaDendrites

SynapseSynapse

11/14/2010 Intelligent Systems and Soft Computing 5

Page 6: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Our brain can be considered as a highly complex, Our brain can be considered as a highly complex, nonnon linear and parallel informationlinear and parallel information processingprocessingnonnon--linear and parallel informationlinear and parallel information--processing 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

t k th th t ifi l ti I tht k th th t ifi l ti I thnetwork, 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 areprocessing are globalglobal rather than localrather than localprocessing 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

l bi l i l l k il bi l i l l k i

11/14/2010 Intelligent Systems and Soft Computing 6

emulate a biological neural network in a computer.emulate a biological neural network in a computer.

Page 7: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

An artificial neural network consists of a number of An artificial neural network consists of a number of very simple processors also calledvery simple processors also called neuronsneurons whichwhichvery simple processors, also called very simple processors, also called neuronsneurons, 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 g g g gg g g gconnection 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.

11/14/2010 Intelligent Systems and Soft Computing 7

Page 8: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Architecture of a typical artificial neural networkArchitecture of a typical artificial neural networks s

g n

a l s

i g n

a l

s

p u

t S

i

p u

t S

i

Middl L

I n p

O u

t p

Input Layer Output Layer

Middle Layer

11/14/2010 Intelligent Systems and Soft Computing 8

Page 9: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Analogy between biological and Analogy between biological and tifi i l l t ktifi i l l t kartificial neural networksartificial neural networks

Biological Neural Network Artificial Neural NetworkSomaD d it

NeuronI tDendrite

AxonSynapse

InputOutputWeight

11/14/2010 Intelligent Systems and Soft Computing 9

Page 10: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The neuron as a simple computing elementThe neuron as a simple computing elementDiagram of aDiagram of a neuronneuron

Input Signals

x1

Output SignalsWeights

x1

x2

Y

w2

w1

Neuron Y Yw2

xnYwn

11/14/2010 Intelligent Systems and Soft Computing 10

Page 11: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The neuron computes the weighted sum of the input The neuron computes the weighted sum of the input signals and compares the result with asignals and compares the result with a thresholdthresholdsignals and compares the result with a signals and compares the result with a threshold threshold valuevalue, , . If the net input is less than the threshold, . If the net input is less than the threshold, the neuron output isthe neuron output is ––1. But if the net input is greater1. But if the net input is greaterthe neuron output is the neuron output is 1. But if the net input is greater 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 functionfunction::functionfunction::

n

ii wxX

11

XX

Yifif,

This type of activation function is called a This type of activation function is called a sign sign

i

ii1

1 Xif,

11/14/2010 Intelligent Systems and Soft Computing 11

ypyp ggfunctionfunction..

Page 12: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Activation functions of a neuronActivation functions of a neuron

Step function Sign function Sigmoid function Linear function

+1 +1Y Y

1 1Y Y

-10

-10X X

-10 X

-10 X

1 1 1

0if,1 Xstep 0if,1 Xsign sigmoid 1 linear

0if,00if,1

XX

Ystep

0if,10if,1

XX

YsignX

sigmoid

eY

1

1 XYlinear

11/14/2010 Intelligent Systems and Soft Computing 12

Page 13: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

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 foralgorithm that provided the first procedure foralgorithm that provided the first procedure for algorithm that provided the first procedure for training a simple ANN: a training a simple ANN: a perceptronperceptron..

The perceptron The perceptron is the simplest form of a neural is the simplest form of a neural network. It consists of a single neuron with network. It consists of a single neuron with dj bldj bl i i h di i h d h d li ih d li iadjustable adjustable synaptic weights and a synaptic weights and a hard limiterhard limiter..

11/14/2010 Intelligent Systems and Soft Computing 13

Page 14: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

SingleSingle--layer twolayer two--input perceptroninput perceptron

InputsInputs

x1 HardLinear

OutputY

Limiterw1 Combiner

Y

w2

Thresholdx2

11/14/2010 Intelligent Systems and Soft Computing 14

Page 15: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

TheThe PerceptronPerceptron

The operation of Rosenblatt’s perceptron is based The operation of Rosenblatt’s perceptron is based on theon the McCulloch and Pitts neuron modelMcCulloch and Pitts neuron model TheTheon the on the McCulloch and Pitts neuron modelMcCulloch 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 limiterhard limiterhard limiter.hard limiter.

The weighted sum of the inputs is applied to the The weighted sum of the inputs is applied to the h d li i hi h d l 1h d li i hi h d l 1hard 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.

11/14/2010 Intelligent Systems and Soft Computing 15

Page 16: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Th i f th t i t l if i tTh i f th t i t l if i t The aim of the perceptron is to classify inputs, The aim of the perceptron is to classify inputs, xx11, , xx22, . . ., , . . ., xxnn, into one of two classes, say , into one of two classes, say AA andand AAAA11 and and AA22..

In the case of an elementary perceptron, the nIn 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 hh li l blli l bl f if ithe the linearly separable linearly separable functionfunction::

n

01

i

iiwx

11/14/2010 Intelligent Systems and Soft Computing 16

Page 17: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Linear separability in the perceptronsLinear separability in the perceptronsx2

Class A1

x2

Class A1

11 2

x1Class A2 x1

1

2

x1w1 + x2w2 = 0 x3x1w1 + x2w2 + x3w3 = 01 1 2 2

(a) Two-input perceptron. (b) Three-input perceptron.

x3 1 1 2 2 3 3

11/14/2010 Intelligent Systems and Soft Computing 17

Page 18: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

How does the perceptron learn its classification How does the perceptron learn its classification tasks?tasks?tasks?tasks?

This is done by making small adjustments in theThis is done by making small adjustments in theThis 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 p p pp p pweights 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.

11/14/2010 Intelligent Systems and Soft Computing 18

Page 19: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

If at iteration If at iteration pp, the actual output is , the actual output is YY((pp) and the ) and the desired output is desired output is YYdd ((pp), then the error is given by:), then the error is given by:

where where p p = 1, 2, 3, . . .= 1, 2, 3, . . .)()()( pYpYpe d

Iteration Iteration p p here refers to the here refers to the ppth training example th training example presented to the perceptron.presented to the perceptron.presented to the perceptron.presented to the perceptron.

If the error, If the error, ee((pp), is positive, we need to increase ), is positive, we need to increase t t tt t t YY(( ) b t if it i ti) b t if it i tiperceptron output perceptron output YY((pp), but if it is negative, we ), but if it is negative, we

need to decrease need to decrease YY((pp).).

11/14/2010 Intelligent Systems and Soft Computing 19

Page 20: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The perceptron learning ruleThe perceptron learning rule

)()()()1( pepxpwpw iii

where where p p = 1, 2, 3, . . . = 1, 2, 3, . . . is the is the learning ratelearning rate, a positive constant less than , a positive constant less than gg , p, punity.unity.

The perceptron learning rule was first proposed byThe perceptron learning rule was first proposed byThe 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 classificationthe perceptron training algorithm for classificationthe perceptron training algorithm for classification the perceptron training algorithm for classification tasks.tasks.

11/14/2010 Intelligent Systems and Soft Computing 20

Page 21: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Perceptron’s training algorithmPerceptron’s training algorithm

Step 1Step 1: Initialisation : Initialisation Set initial weightsSet initial weights ww ww ww and thresholdand threshold Set initial weights Set initial weights ww11, , ww22,…, ,…, wwnn 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, ee((pp), is positive, we need to increase ), is positive, we need to increase perceptronperceptron output output YY((pp), but if it is negative, we ), but if it is negative, we

d dd d YY(( ))need to decrease need to decrease YY((pp).).

11/14/2010 Intelligent Systems and Soft Computing 21

Page 22: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Perceptron’s training algorithm (continued)Perceptron’s training algorithm (continued)

Step 2Step 2: Activation : Activation Activate the perceptron by applying inputs Activate the perceptron by applying inputs xx11((pp), ), p p y pp y g pp p y pp y g p 11((pp),),xx22((pp),…, ),…, xxnn((pp) and desired output ) and desired output YYdd ((pp). ). Calculate the actual output at iteration Calculate the actual output at iteration p p = 1= 1

nii pwpxsteppY )()()(

where where n n is the number of the perceptron inputs, is the number of the perceptron inputs,

i 1

p p pp p pand and step step is a step activation function.is a step activation function.

11/14/2010 Intelligent Systems and Soft Computing 22

Page 23: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Perceptron’s training algorithm (continued)Perceptron’s training algorithm (continued)St 3St 3 W i ht t i iW i ht t i iStep 3Step 3: Weight training : Weight training

Update the weights of the perceptronUpdate the weights of the perceptron)()()1(

where where wwii((pp) is the weight correction at iteration ) is the weight correction at iteration pp..)()()1( pwpwpw iii

The weight correction is computed by the The weight correction is computed by the delta delta rulerule::rulerule::

)()()( pepxpw ii .

Step 4Step 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

11/14/2010 Intelligent Systems and Soft Computing 23

repeat the process until convergence.repeat the process until convergence.

Page 24: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Example of perceptron learning: the logical operation Example of perceptron learning: the logical operation ANDANDInputs

EpochDesiredoutput

Initialweights

Actualoutput

Error Finalweights

x1 x2001

010

000

Epoch outputYd

1

weightsw1 w20.30.30.3

0.10.10 1

001

outputY e

00

1

weightsw1 w20.30.30.2

0.10.10 11

101

01

0.30.2

0.10.1

10

11

0.20.3

0.10.0

001

010

000

2 0.30.30 3

001

001

0.30.30 2

0.00.00 0

0.00.00 01

101

01

0.30.2

11

10

0.20.2

0.00.0

001

010

000

3 0.20.20.2

0.00.0

0.00.00.0

001

001

0.20.20.1

0.00.00.01

101

01

0.20.1

0.00.0

10

11

0.10.2

0.00.1

001

010

000

4 0.20.20.2

0.10.10.1

001

00

1

0.20.20.1

0.10.10.11

101

01

0.20.1

0.10.1

11

10

0.10.1

0.10.1

001

010

000

5 0.10.10.1

0.10.10.1

000

00

0.10.10.1

0.10.10.10

11/14/2010 Intelligent Systems and Soft Computing 24

11

01

01

0.10.1

0.10.1

01 0

0.10.1

0.10.1

Threshold: = 0.2; learning rate: = 0.1

Page 25: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

TwoTwo--dimensional plots of basic logical operationsdimensional plots of basic logical operationsx2 x2 x2

x1

1

x1

1

x1

1

1 1

(b) OR (x1 x2)

1

(c) Exclus ive-OR

00 0

(a) AND (x x )

A perceptron can learn the operationsA perceptron can learn the operations ANDAND andand OROR

(b) OR (x1 x2) (c) Exclus ive-OR(x1 x2)

(a) AND (x1 x2)

A perceptron can learn the operations A perceptron can learn the operations AND AND and and OROR, , but not but not ExclusiveExclusive--OROR..

11/14/2010 Intelligent Systems and Soft Computing 25

Page 26: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

MultilayerMultilayer neuralneural networksnetworks

A multilayer perceptron is a feedforward neural A multilayer perceptron is a feedforward neural network with one or more hidden layersnetwork with one or more hidden layersnetwork 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

i li lcomputational neurons.computational neurons.

The input signals are propagated in a forward The input signals are propagated in a forward p g p p gp g p p gdirection on a layerdirection on a layer--byby--layer basis.layer basis.

11/14/2010 Intelligent Systems and Soft Computing 26

Page 27: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Multilayer perceptron with two hidden layersMultilayer perceptron with two hidden layersy p p yy p p yll

i g n

a l

i g n

a l

S i g

n

S i g

n

p u

t S

ip u

t S

i

p u

t S

p u

t S

First Second

I n p

I n p

ss

O u

ta l s

a l s

Inputlayer

hiddenlayer

hiddenlayer

Outputlayer

11/14/2010 Intelligent Systems and Soft Computing 27

Page 28: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

What does the middle layer hide?What does the middle layer hide? A hidd l “hid ” it d i d t tA hidd l “hid ” it d i d t t 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 behavior of the networkthrough the input/output behavior of the networkthrough the input/output behavior of the network. through the input/output behavior 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 beoutput of the hidden layer should beoutput of the hidden layer should be.output of the hidden layer should be.

Commercial ANNs incorporate three and Commercial ANNs incorporate three and i f l i l dii f l i l disometimes 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 E i t l l t k1000 E i t l l t k1000 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 utilize millions of neuronsfour hidden layers and utilize millions of neurons

11/14/2010 Intelligent Systems and Soft Computing 28

four hidden layers, and utilize millions of neurons.four hidden layers, and utilize millions of neurons.

Page 29: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

BackBack--propagation neural networkpropagation 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 networknetworknetwork.network.

The network computes its output pattern, and if The network computes its output pattern, and if th ith i i th d diffi th d diffthere 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 errorweights are adjusted to reduce this errorweights are adjusted to reduce this error.weights are adjusted to reduce this error.

11/14/2010 Intelligent Systems and Soft Computing 29

Page 30: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

In a backIn a back--propagation neural network, the learning propagation neural network, the learning p p g , gp p g , galgorithm has two phases. algorithm has two phases.

First a training input pattern is presented to theFirst a training input pattern is presented to the 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 outputinput pattern from layer to layer until the outputinput 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 thi tt i diff t f th d i d t tIf thi tt i diff t f th d i d t t 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 outputbackwards through the network from the outputbackwards 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 propagatedas the error is propagated

11/14/2010 Intelligent Systems and Soft Computing 30

as the error is propagated.as the error is propagated.

Page 31: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

ThreeThree--layer backlayer back--propagation neural networkpropagation neural network

x11

1 y1

Input signals

x22

2

y1

y2

1

2

xii

k ykwjkwij j

xnn l yl

m

Inputlayer

xnOutputlayer

Hiddenlayer

11/14/2010 Intelligent Systems and Soft Computing 31

Error signals

Page 32: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The backThe back--propagation training algorithmpropagation training algorithmStep 1Step 1: Initialization : Initialization

Set all the weights and threshold levels of the Set all the weights and threshold levels of the ggnetwork to random numbers uniformly network to random numbers uniformly distributed inside a small range:distributed inside a small range:

4.2,4.2

wherewhere FFii is the total number of inputs of neuronis the total number of inputs of neuron ii

ii FF

,

where where FFii is the total number of inputs of neuron is the total number of inputs of neuron i i in the network. The weight initialization is done in the network. The weight initialization is done on a neuronon a neuron--byby--neuron basis.neuron basis.

11/14/2010 Intelligent Systems and Soft Computing 32

yy

Page 33: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Step 2Step 2: Activation : Activation Activate the backActivate the back propagation neural network bypropagation neural network byActivate the backActivate the back--propagation neural network by propagation neural network by applying inputs applying inputs xx11((pp), ), xx22((pp),…, ),…, xxnn((pp) and desired ) and desired outputsoutputs yydd 11((pp)) yydd 22((pp)) yydd ((pp))outputs outputs yydd,1,1((pp), ), yydd,2,2((pp),…, ),…, yydd,,nn((pp).).

((aa) Calculate the actual outputs of the neurons in ) Calculate the actual outputs of the neurons in h hidd lh hidd lthe hidden layer:the hidden layer:

n

pwpxsigmoidpy )()()(

hh i th b f i t fi th b f i t f jj i thi th

ji

ijij pwpxsigmoidpy1

)()()(

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 functionfunction

11/14/2010 Intelligent Systems and Soft Computing 33

function.function.

Page 34: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

((bb) C l l t th t l t t f th i) C l l t th t l t t f th iStep 2Step 2 : Activation (continued): Activation (continued)

((bb) Calculate the actual outputs of the neurons in ) Calculate the actual outputs of the neurons in the output layer:the output layer:

k

m

jjkjkk pwpxsigmoidpy

1)()()(

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 layeroutput layer

j 1

output layer.output layer.

11/14/2010 Intelligent Systems and Soft Computing 34

Page 35: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Step 3Step 3: Weight training : Weight training Update the weights in the backUpdate the weights in the back--propagation networkpropagation networkUpdate the weights in the backUpdate the weights in the back propagation network propagation network propagating backward the errors associated with propagating backward the errors associated with output neurons. output neurons. pp((aa) Calculate the error gradient for the neurons in the ) Calculate the error gradient for the neurons in the output layer:output layer:p yp y

wherewhere

)()(1)()( pepypyp kkkk

)()()( pypype wherewhereCalculate the weight corrections:Calculate the weight corrections:

)()()( , pypype kkdk

)()()(

Update the weights at the output neurons:Update the weights at the output neurons:)()()( ppypw kjjk

11/14/2010 Intelligent Systems and Soft Computing 35

)()()1( pwpwpw jkjkjk

Page 36: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

((bb) C l l t th di t f th i) C l l t th di t f th iStep 3Step 3: Weight training (continued): Weight training (continued)

((bb) Calculate the error gradient for the neurons in ) Calculate the error gradient for the neurons in the hidden layer:the hidden layer:

l)()()(1)()(

1][ pwppypyp jk

l

kkjjj

Calculate the weight corrections:Calculate the weight corrections:

)()()( ppxpw jiij

Update the weights at the hidden neurons:Update the weights at the hidden neurons:

)()()( ppxpw jiij

)()()1( pwpwpw ijijij

11/14/2010 Intelligent Systems and Soft Computing 36

Page 37: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Step 4Step 4: Iteration : Iteration Increase iterationIncrease iteration pp by one go back toby one go back to Step 2Step 2 andandIncrease 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 satisfiedis satisfiedis satisfied.is satisfied.

As an example, we may consider the threeAs an example, we may consider the three--layer layer b kb k i k S h hi k S h hbackback--propagation network. Suppose that the propagation network. Suppose that the network is required to perform logical operation network is required to perform logical operation E l iE l i OROR Recall that a singleRecall that a single la er perceptronla er perceptronExclusiveExclusive--OROR. Recall that a single. Recall that a single--layer perceptron layer perceptron could not do this operation. Now we will apply the could not do this operation. Now we will apply the threethree layer netlayer netthreethree--layer net.layer net.

11/14/2010 Intelligent Systems and Soft Computing 37

Page 38: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

ThreeThree--layer network for solving the layer network for solving the E l iE l i OR tiOR tiExclusiveExclusive--OR operationOR operation

1

x1 31

3w13

w

1

y55

x1 31w23

w35 5

x2 42w24

w24 w45

Inputlayer

Outputlayer

w244

1

11/14/2010 Intelligent Systems and Soft Computing 38

Hiddenlayer1

Page 39: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The effect of the threshold applied to a neuron in the The effect of the threshold applied to a neuron in the pppphidden 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:randomly as follows: randomly as follows: ww1313 = 0.5, = 0.5, ww1414 = 0.9, = 0.9, ww2323 = 0.4, = 0.4, ww2424 = 1.0, = 1.0, ww35 35 = = 1.2, 1.2, ww4545 = 1.1,= 1.1, 33 = 0.8,= 0.8, 44 == 0.1 and0.1 and 55 = 0.3.= 0.3.ww4545 1.1, 1.1, 33 0.8, 0.8, 44 0.1 and 0.1 and 55 0.3. 0.3.

11/14/2010 Intelligent Systems and Soft Computing 39

Page 40: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

We consider a training set where inputs We consider a training set where inputs xx1 1 and and xx22 are are equal to 1 and desired outputequal to 1 and desired output yy is 0 The actualis 0 The actualequal to 1 and desired output equal to 1 and desired output yydd,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 ascalculated ascalculated ascalculated as

5250.01/1)( )8.014.015.01(32321313 ewxwxsigmoidy

)101011901(

Now the actual output of neuron 5 in the output layer Now the actual output of neuron 5 in the output layer 8808.01/1)( )1.010.119.01(

42421414 ewxwxsigmoidy

is determined as:is determined as:

509701/1)( )3.011.18808.02.15250.0(54543535 ewywysigmoidy

Thus, the following error is obtained:Thus, the following error is obtained:5097.01/1)( 54543535 ewywysigmoidy

11/14/2010 Intelligent Systems and Soft Computing 40

5097.05097.0055, yye d

Page 41: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

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, ee, from the output layer , from the output layer b k d t th i t lb k d t th i t lbackward 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.05097).0(0.5097)(10.5097)1( 555 eyy

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: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.01.05445 yw0067.0)1274.0(5250.01.05335 yw

11/14/2010 Intelligent Systems and Soft Computing 41

0112.0)1274.0(8808.01.05445 yw0127.0)1274.0()1(1.0)1( 55

Page 42: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Next we calculate the error gradients for neurons 3 Next we calculate the error gradients for neurons 3 ggand 4 in the hidden layer:and 4 in the hidden layer:

03810)21(0 1274)(0 5250)(10 5250)1( 355333 wyy 0381.0)2.1(0.1274)(0.5250)(10.5250)1( 355333 wyy

0.0147.114)0.127(0.8808)(10.8808)1( 455444 wyy

We then determine the weight corrections:We then determine the weight corrections:0038.00381.011.03113 xw0038.00381.011.03223 xw

0038.00381.0)1(1.0)1( 33 0015.0)0147.0(11.04114 xw )(41140015.0)0147.0(11.04224 xw

0015.0)0147.0()1(1.0)1( 44

11/14/2010 Intelligent Systems and Soft Computing 42

Page 43: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

At last, we update all weights and threshold:At last, we update all weights and threshold:

5038.00038.05.0131313 www8985.00015.09.0141414 www

4038.00038.04.0232323 www

9985.00015.00.1242424 www

2067.10067.02.1353535 www

0888.10112.01.1454545 www

7962.00038.08.0333

0985.00015.01.0444

The training process is repeated until the sum ofThe training process is repeated until the sum of3127.00127.03.0555

11/14/2010 Intelligent Systems and Soft Computing 43

squared errors is less than 0.001.squared errors is less than 0.001.

Page 44: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Learning curve for operation Learning curve for operation ExclusiveExclusive--OROR10 1

Sum-Squared Network Error for 224 Epochs

100

rror

10-1

2-Squ

ared

Er

10-2

10 -3

Sum

-

10

10 -4

11/14/2010 Intelligent Systems and Soft Computing 44

0 50 100 150 200Epoch

10

Page 45: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Final results of threeFinal results of three--layer network learninglayer network learning

Inputs Desiredoutput

Actualoutput

Sum ofsquared

x1 x2

1 1 0

outputyd

0 0155

outputy5 e

squarederrors0 00101

01

110

011

0.01550.98490.9849

0.0010

000 0 0.0175

11/14/2010 Intelligent Systems and Soft Computing 45

Page 46: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Network represented by McCullochNetwork represented by McCulloch--Pitts model Pitts model for solving thefor solving the ExclusiveExclusive OROR operationoperationfor solving the for solving the ExclusiveExclusive--OR OR operationoperation

1

x1 311

+1.0+1.5

y55

x1 31+1.0 +0.52.0

y55

x2 42+1.0 +1.0

2 +1.0+0.5

11/14/2010 Intelligent Systems and Soft Computing 46

1

Page 47: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Decision boundariesDecision boundariesx2 x2

x1 + x2 – 1.5 = 0 x1 + x2 – 0.5 = 0x2

x1

1 1

x1 x1

1

11

( )

1

(b)

001 1

1

( )

0

(a)(a) DecisionDecision boundary constructed by hidden neuron 3;boundary constructed by hidden neuron 3;

(a) (b) (c)

(a)(a) DecisionDecision boundary constructed by hidden neuron 3; boundary constructed by hidden neuron 3; ((bb) Decision boundary constructed by hidden neuron 4; ) Decision boundary constructed by hidden neuron 4; ((cc) Decision boundaries constructed by the complete ) Decision boundaries constructed by the complete

11/14/2010 Intelligent Systems and Soft Computing 47

(( ) y p) y pthreethree--layer networklayer network

Page 48: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Accelerated learning in multilayer Accelerated learning in multilayer neural networksneural networks

A multilayer network learns much faster when the A multilayer network learns much faster when the yysigmoidal activation function is represented by a sigmoidal activation function is represented by a hyperbolic tangenthyperbolic tangent::

aeaY bX

htan

12

where where a a and and bb are constants.are constants.e1

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.= 0.667667

11/14/2010 Intelligent Systems and Soft Computing 48

Page 49: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

W l l t t i i b i l diW l l t t i i b i l diWe 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:

)()()1()( ppypwpw kjjkjk

where where is a positive number (0 is a positive number (0 1) called the 1) called the momentum constantmomentum 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 rulegeneralised delta rule..

11/14/2010 Intelligent Systems and Soft Computing 49

Page 50: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Learning with momentum for operation Learning with momentum for operation ExclusiveExclusive--ORORTraining for 126 Epochs

10 0

10 2Training for 126 Epochs

10 1

10 -2

10 -3

10 -1

0 20 40 60 80 100 12010 -4

Epoch

1 5

0.5

1

1.5

g R

ate

1

-0.5

0

Lea

rnin

g

11/14/2010 Intelligent Systems and Soft Computing 50

0 100 140-1

Epoch20 40 60 80 120

Page 51: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Learning with adaptive learning rateLearning with adaptive learning rateTo 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 1Heuristic 1If the change of the sum of squared errors has the same If the change of the sum of squared errors has the same g qg qalgebraic 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 2Heuristic 2If the algebraic sign of the change of the sum of If the algebraic sign of the change of the sum of g g gg g gsquared 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

11/14/2010 Intelligent Systems and Soft Computing 51

decreased.decreased.

Page 52: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Adapting the learning rate requires some changes Adapting the learning rate requires some changes p g g q gp g g q gin the backin the back--propagation algorithm. propagation algorithm.

If the sum of squared errors at the current epochIf the sum of squared errors at the current epoch 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 p ( yp y ), gp ( yp y ), gparameter 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 p ,p ,learning rate is increased (typically by multiplying learning rate is increased (typically by multiplying by 1.05).by 1.05).

11/14/2010 Intelligent Systems and Soft Computing 52

Page 53: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Learning with adaptive learning rateLearning with adaptive learning rateTr ainingfor 103EpochsTr ainingfor 103Epochs

100

102

101

ed

ed

10-2

10 -3

10 -1

Sum

Sum

--Square

Square

Err

oErr

o

0 10 20 30 40 50 60 70 80 90 100Epoch

1

10-4

SS EE

0.6

0.8

1

ng

ng

0

0.2

0.4

Learn

inLearn

inR

ate

Rate

11/14/2010 Intelligent Systems and Soft Computing 53

0 20 40 60 80 100 1200

Epoch

Page 54: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Learning with momentum and adaptive learning rateLearning with momentum and adaptive learning rateTrainingfor 85 EpochsTrainingfor 85 Epochs

100

102

101

are

d

are

d

10-2

10 -3

10 -1

Sum

Sum

--Squa

Squa

Err

oErr

o

0 10 20 30 40 50 60 70 80Epoch

2 5

10-4

2.5

1.5

2

ng

ng

0

0.5

1

Learn

inLearn

inR

ate

Rate

11/14/2010 Intelligent Systems and Soft Computing 54

0 10 20 30 40 50 60 70 80 900

Epoch

Page 55: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The Hopfield NetworkThe Hopfield Network

Neural networks were designed on analogy with Neural networks were designed on analogy with the brain The brain’s memory however works bythe brain The brain’s memory however works bythe brain. The brain s memory, however, works by the brain. The brain s memory, however, works by association. For example, we can recognise a association. For example, we can recognise a familiar face even in an unfamiliar environmentfamiliar face even in an unfamiliar environmentfamiliar face even in an unfamiliar environment familiar face even in an unfamiliar environment within 100within 100--200 ms. We can also recall a complete 200 ms. We can also recall a complete sensory experience, including sounds and scenes, sensory experience, including sounds and scenes, y p , g ,y p , g ,when we hear only a few bars of music. The brain when we hear only a few bars of music. The brain routinely associates one thing with another.routinely associates one thing with another.y gy g

11/14/2010 Intelligent Systems and Soft Computing 55

Page 56: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Multilayer neural networks trained with the backMultilayer neural networks trained with the back--yypropagation 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

l kl kneural networkneural network..

A recurrent neural network has feedback loops A recurrent neural network has feedback loops ppfrom 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.

11/14/2010 Intelligent Systems and Soft Computing 56

Page 57: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The stability of recurrent networks intrigued The stability of recurrent networks intrigued y gy gseveral 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 t i i f ti i d i ll t blt i i f ti i d i ll t blstoring information in a dynamically stable storing information in a dynamically stable

network.network.

11/14/2010 Intelligent Systems and Soft Computing 57

Page 58: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

SingleSingle--layer layer nn--neuron Hopfield networkneuron Hopfield network

x1 y11

x2 y22

xi yii

xn ynn

11/14/2010 Intelligent Systems and Soft Computing 58

Page 59: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

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

sign0if,1

XYXYsign

if,if,1

11/14/2010 Intelligent Systems and Soft Computing 59

Page 60: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

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, yy11, , yy22, . . ., , . . ., yynn..

Thus, for a singleThus, for a single--layer layer nn--neuron network, the state neuron network, the state can be defined by the can be defined by the state vector state vector as:as:yy

y1

y 2Y

ny

11/14/2010 Intelligent Systems and Soft Computing 60

Page 61: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

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:

IYYW MM

Tmm

1

where where MM is the number of states to be is the number of states to be memorisedmemorised

m1

by the network, by the network, YYmm is the nis the n--dimensional binary dimensional binary vector, I is n x n identity matrix, and superscript vector, I is n x n identity matrix, and superscript T T d i i id i i idenotes matrix transposition.denotes matrix transposition.

11/14/2010 Intelligent Systems and Soft Computing 61

Page 62: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Possible states for the threePossible states for the three--neuron neuron H fi ld t kH fi ld t kHopfield networkHopfield network

y2

(1, 1,1)(1,1,1)

y1

(1, 1, 1)(1, 1, 1)

(1,1,1) (1,1,1)

0

(1 1 1)( 1 1 1)

( , , ) ( )

11/14/2010 Intelligent Systems and Soft Computing 62

y3(1,1, 1)(1,1, 1)

Page 63: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The stable stateThe stable state--vertex is determined by the weight vertex is determined by the weight matrixmatrix WW the current input vectorthe current input vector XX and theand thematrix matrix WW, the current input vector , the current input vector XX, 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 convergeincorrect or incomplete, the initial state will convergeincorrect or incomplete, the initial state will converge incorrect or incomplete, the initial state will converge into the stable stateinto the stable state--vertex after a few iterations.vertex after a few iterations.

Suppose for instance that our network is required toSuppose for instance that our network is required to 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,,,

oror

11

1Y

11

2Y 1111 TY 1112 TY

hh YY dd YY th thth th di i l tdi i l t

1

1

1

2 2

11/14/2010 Intelligent Systems and Soft Computing 63

where where YY11 and and YY22 are the threeare the three--dimensional vectors.dimensional vectors.

Page 64: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The 3 The 3 ´́ 3 identity matrix 3 identity matrix I I isis 001

100010001

I

Thus, we can now determine the weight matrix as Thus, we can now determine the weight matrix as follows:follows:

100

follows:follows:

00111

220

1000102111

11111

11W

022202

Next, the network is tested by the sequence of input Next, the network is tested by the sequence of input vectors, vectors, XX11 and and XX22, which are equal to the output (or, which are equal to the output (or

11/14/2010 Intelligent Systems and Soft Computing 64

11 22target) vectors target) vectors YY11 and and YY22, respectively., respectively.

Page 65: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

First, we activate the Hopfield network by applying First, we activate the Hopfield network by applying the input vectorthe input vector XX Then we calculate the actualThen we calculate the actualthe input vector the input vector XX. Then, we calculate the actual . Then, we calculate the actual output vector output vector YY, and finally, we compare the result , and finally, we compare the result with the initial input vectorwith the initial input vector XXwith the initial input vector with the initial input vector XX. .

101220

11

00

11

0222021 signY

101220

11

00

11

0222022 signY

11/14/2010 Intelligent Systems and Soft Computing 65

Page 66: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The remaining six states are all unstable. However, The remaining six states are all unstable. However, stable states (also calledstable states (also called fundamental memoriesfundamental memories) are) arestable states (also calledstable states (also called fundamental memoriesfundamental memories) are ) are capable of attracting states that are close to them.capable of attracting states that are close to them.

Th f d t l (1 1 1) tt t t blTh f d t l (1 1 1) tt t t bl 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 1). Each of these unstable states represents a single errorthese unstable states represents a single errorthese unstable states represents a single error, these unstable states represents a single error, compared to the fundamental memory (1, 1, 1). compared to the fundamental memory (1, 1, 1).

Th f d t l (Th f d t l ( 11 11 1) tt t1) tt t The fundamental memory (The fundamental memory (1, 1, 1, 1, 1) attracts 1) attracts unstable states (unstable 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 networkcorrection network..

11/14/2010 Intelligent Systems and Soft Computing 66

Page 67: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Storage capacity of the Hopfield networkStorage capacity of the Hopfield network

Storage capacity Storage capacity is is the largest number of the largest number of fundamental memories that can be stored andfundamental memories that can be stored andfundamental 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 MMmaxmax that can be stored in the that can be stored in the nn--neuron recurrent neuron recurrent

t k i li it d bt k i li it d bnetwork is limited bynetwork is limited by

On the basis that On the basis that mostmost of the fundamental memories of the fundamental memories nMmax 0.15

are to be retrieved perfectly: are to be retrieved perfectly: MMmaxmax=n/2ln n=n/2ln n

11/14/2010 Intelligent Systems and Soft Computing 67

Page 68: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Bidirectional associative memory (BAM)Bidirectional associative memory (BAM) The Hopfield network represents an The Hopfield network represents an autoauto--associative associative

type of memory type of memory it can retrieve a corrupted or it can retrieve a corrupted or i l b i hii l b i hiincomplete 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 associativeassociative. . 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

W h i f t l i ti tW h i f t l i ti ton. 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 whatumbrella we try to recall where we last had it whatumbrella, 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

11/14/2010 Intelligent Systems and Soft Computing 68

thereby to restore a lost memory.thereby to restore a lost memory.

Page 69: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

To associate one memory with another, we need a To associate one memory with another, we need a recurrent neural network capable of accepting anrecurrent neural network capable of accepting anrecurrent 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 anothera related but different output pattern on anothera related, but different, output pattern on another a related, but different, output pattern on another set of neurons.set of neurons.

Bidi ti l i ti (BAM)Bidi ti l i ti (BAM) fifi Bidirectional associative memory (BAM)Bidirectional associative memory (BAM), first , first proposed by proposed by Bart Bart KoskoKosko, is a , is a heteroassociativeheteroassociativenetwork It associates patterns from one set setnetwork It associates patterns from one set set AAnetwork. It associates patterns from one set, set network. It associates patterns from one set, set AA, , to patterns from another set, set to patterns from another set, set BB, and vice versa. , and vice versa. Like a Hopfield network the BAM can generalizeLike a Hopfield network the BAM can generalizeLike a Hopfield network, the BAM can generalize Like a Hopfield network, the BAM can generalize and also produce correct outputs despite corrupted and also produce correct outputs despite corrupted or incomplete inputs.or incomplete inputs.

11/14/2010 Intelligent Systems and Soft Computing 69

or incomplete inputs.or incomplete inputs.

Page 70: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

BAM operationBAM operation

( )

x1(p) 1 x1(p+1)

( )

1

y1(p)

y2(p)

1

2x2(p) 2 x2(p+1)

y1(p)

y2(p)

1

22

yj(p)jxi(p) i xi(p+1) yj(p)ji

ym(p)m

x (p) n x (p+1)

ym(p)m

n

Outputlayer

Inputlayer

xn(p) n xn(p+1)Outputlayer

Inputlayer

n

11/14/2010 Intelligent Systems and Soft Computing 70

(a) Forward direction. (b) Backward direction.

Page 71: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

The basic idea behind the BAM is to store The basic idea behind the BAM is to store tt i th t htt i th t h di i l tdi i l tpattern pairs so that when pattern pairs so that when nn--dimensional vector dimensional vector

X X from set from set A A is presented as input, the BAM is presented as input, the BAM llll di i l tdi i l t YY f tf t BB b tb trecalls recalls mm--dimensional vector dimensional vector Y Y from set from set BB, but , but

when when Y Y is presented as input, the BAM recalls is presented as input, the BAM recalls XX..

11/14/2010 Intelligent Systems and Soft Computing 71

Page 72: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

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 XX, and the transpose of the , and the transpose of the output vector output vector YYTT. The BAM weight matrix is the . The BAM weight matrix is the

f ll l i i h if ll l i i h isum of all correlation matrices, that is,sum of all correlation matrices, that is,

TM

YXW Tm

mm YXW

1

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.

11/14/2010 Intelligent Systems and Soft Computing 72

Page 73: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

How does BAM work?How does BAM work?

The input vector X (p) is applied to the transpose of The input vector X (p) is applied to the transpose of weight matrix Wweight matrix WTT to produce an output vector Y(p)to produce an output vector Y(p)weight matrix Wweight matrix WT T to produce an output vector Y(p). to produce an output vector Y(p). Then, the output vector Y(p) is applied to the Then, the output vector Y(p) is applied to the weight matrix W to produce a new input vectorweight matrix W to produce a new input vectorweight matrix W to produce a new input vector weight matrix W to produce a new input vector X(p+1). This process is repeated until input and X(p+1). This process is repeated until input and output vector become unchanged, or in other words, output vector become unchanged, or in other words, output vecto beco e u c a ged, o ot e wo ds,output vecto beco e u c a ged, o ot e wo ds,the BAM reaches stable state.the BAM reaches stable state.

11/14/2010 Intelligent Systems and Soft Computing 73

Page 74: Supervised learningSupervised learningrahimi/cs437/slides/lec07.pdf · Lecture 7 Artificial neural networks: Supervised learningSupervised learning Introduction, or how the brain

Stability and storage capacity of the BAMStability and storage capacity of the BAM The BAM is The BAM is unconditionally stableunconditionally 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 i t biliti t bilitinstability.instability.

The maximum number of associations to be stored in The maximum number of associations to be stored in the BAM should not exceed the number of 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 convergenceincorrect convergence. The BAM may not . The BAM may not co ect co ve ge ceco ect co ve ge ce. e ay ot. e ay otalways 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

11/14/2010 Intelligent Systems and Soft Computing 74

y y g yy y g ythe initial input vector.the initial input vector.