Perceptron Network
Perceptron Network
Networks
4.1 Introduction
119621,and Minsky and Papert [19881,developed large class of artificial neural
Frank Rosenblatt
Perceptrons. 'Ibe perceptron learning rule uses an iterative weight adjustment that is
networks called
than the Hebb rule. The perceptrons use threshold output function and the McCulloch-
more powerful
neuron. Their iterativelearningconvergesto correctweighty,i.e. the weightsthat
Pitts model of a output value for the training input pattern. The original
perceptron is found to have
produce the exact associator and response units as shown in Fig. 4.1.
sensory,
three layers,
61
l ien rptron Networks
Original Perceptron
Thesensory and association units have binary activations and an activation of + I , 0 or— I iQug,edfor
theresponseunit. All the units have their con•espondingweighted interconnections.Training in rrrceptron
u.illcontinueuntil no error occurs. ms net solves the problem and is also used to learn the classifica-
non.The perceptrons are of two types: single layer and multi layer perceptrons. A detailed study about
thepcrccptronnetworks is made in this chapter.
4.2.1 Architecture
Fig. 4.2.
Thearchitectureof the single layer perceptron is shown in
sensory, associator and response units. The input to
As we have already studied, the perceptron has
unit, which is a binary vector. Since only the
the responseunit will be the output from the associator
adjusted, the concept is limited to single layer
weightbetween the associator and the response unit is
networkas discussed in Section 2.7.
unit and the response unit is shown. The
In the architecture shown in fig. 4.2, only the associator
response unit are
sensorunit is hidden,because only the weights between the associator and the
n. There always exists a com-
adjusted.The input layer consists of input neurons from Xl Xi x
through weighted intercon-
monbias of 'l'. The input neurons are connected to the output neurons
interconnectionsbetween
nections.This is a single layer network because it has only one layer of
input signal received and performs the
the input and the output neurons. This network perceives the
classification.
62 to
4.2.2 Algorithm
To start the training process, initially the weights and the bias are set to zero. The initial weights of the
network can be formulated from other techniqueslike Fuzzy systems, Genetic Algorithm etc. It is also
essential to set the learning rate parameter, which ranges between 0 to 1. Then the input is presented, the
net input is calculated by multiplying the weights with the inputs and adding the result with the bias
entity. Once the net input is calculated, by applying the activation function the output of the network is
also obtained. This output is compared with the target, where if any difference occurs, we go in for
weight updation based on perceptron learning rule, else the network training is stopped. The algorithm
can be used for both binary and bipolar input vectors. It uses a bipolar target with fixed threshold and
adjustable bias.
The training algorithm is as follows:
Step 1: Initialize weights and bias (initially it can be zero). Set learning rate to 1).
Step 2: While stopping condition is false do Steps 3—7.
Step 3: For each training pair s:t do Steps 4—6.
Step 4: Set activations of input units.
Xi= sj for i = 1 ton
Step 5: Compute the output unit response.
el.se
Anew) W'(old)
b (new)=
(old)'
Step 7: Test for stopping condition.
stopping conditions may be the weight
changes.
vote:
1. Only weights connecting active input units (Xi#0)
are updated.
2. Weights are updated only for patterns that do not
produce the correct value of
0
Y-in >
0 If —0 < y_in SO
-1, If Y-in O
O. if
l. if
and bias atv•to updated for j e I to m and i 1 to n.
Step 6:
It N, t, and v, 0. then
b(old) at,
cisc If
= wv(old)
Example 4.1 Develop a perceptron for the AND function with bipolar inputs and targets.
Solution The training pattern for AND function can be,
Input Target
b t
1 1 1 1
-1 1 1 -1
1 -1 1 -1
-1 -1 1 -1
Step 1: Initial weights WI= = 0 and b = 0, a = 1, 0 = 0.
Step 2: Begin computation.
Step 3: For input pair (l, l): l, do Steps 4—6
Step 4: Set activauons of input units
(-1)
Example 4.2 Develop a perceptron for the AND function with binary inputs and bipolar targets without
bias up to 2 epochs. (Take first with (0,()) and next without (0,0)).
Solution Initializing the weights to be, WI w2 = 0 and the bias is neglected here (because the problem is
stated without bias). Hence a I and threshold 0 = O.
(a) With(0,0) and without bias.
Intnkiuctionto ScunJl Nctuorks
net input
O, if
if y _in < — O
weight change,
Awi = and
New weight is.
(new) = w(old) + Aw
Epoch 1:
Input Net Output Target Weight Changes Weights
AWI
(0 0)
The separating line for 1st and 2nd input are, Xl+ x2 = 0 and x2 = 0 respectively.
Epoch 2:
The initial weights used are the final weights from the pervious iteration.
Without bias for the given inputs, the final weights obtained are same as that for with bias and the equation
of separating line also remains same. Thus the equations remain same and are given by,
for 1st input
for 2nd input
(b) Without bias and (0,0)
Epoch 1:
Input Net Output Target Weight Changes Weights
(0 0)
Epoch 2:
The final weights from Epoch I are used here as initial weights,
Input Net Output Ilu•get Weight Changes Weights
AWI
(0 0)
2nd input
Thus from all this, it is clear that without bias the convergence does not occur. Even after neglecting (0, 0),
the convergence does not occur.
Example 4.3 Using the perceptron learning rule, find the weights required to perform the following clas-
sifications. Vectors (1 1 1 1), (—1 1 —1 —1) and (1 —1 —1 1) are members of class (having target value l);
vectors (1 1 1 —1) and (1 —1 —1 1) are not members of class (having target value —1). Use learning rate of 1
and starting weights of 0. Using each of the training and vectors as input, test the response of the net.
Solution The initial weights are assumed to be zero and the learning rate as 1.
The updation is done according to perceptron learning rule,
If y t, weight change, Aw = octXi& Ab = Oct.
-1
Epoch 2: initial --9
00020
00020
Initial —i
-1
-1
The final weights from Epoch 1 are used as the initial weights for Epoch 2. Thus the output is equaltotarget
by training for suitable weights.
Testing the response of the net
The final weights are,
For the 1st set of input, WI= 0, w2 = 0, w3 = 0, w4 = 2, b = 0, and
For the 2nd set of input, WI =— 1, 1 w3 = —1, w4 = -- 1, b = 1
Applying activations,
69
calculated teq output matcheq with tArget the Input
0) Correct
(1
Undetemined
(1 0)
(1 0)
Undetermined
is given as follows.
The MATLAB program for the above table
70 Introduction to Neural Networks
6.
Program
*Perceptron for AND funtion
clear:
clc:
if yin<-theta
end
if y-t(i)
con-I;
for J-1:2
end
end
epoch-epoch+l :
end
disp( 'Perceptron for ANDfunt)on•)
disp(' Final Wenght
matru').
disp(w):
dl€p( •FInal Bias').
disp(b):
Output
Enter Learmrtgrate-I
Enter Threshold value-C.S
Perceptron for ANDtunvon
F Ina 1 Weight n;atmx
1 1
Final Elas
Perr eptrrpnNetworks
The numbers are fonncd from the 5 x 3 matrix and thc input
Olgtton data file is determined. The input data
are given. The data are stored
and the test data files in a file called 'reg.mat% When the test data is given.
recognized then it is + l, and if the pattern is not recognized,
ifthcpatternis it is L
pgt* - reg.mat
01 1 11 1 1;
1100111011;
0100000000;
1011100111;
1010001010;
0100000000;
0100000000;
0010000000;
0001000000;
0000100000;
0000010000;
0000001000;
0000000100;
0000000010;
0000000001;]
11001;
Neural
01001.
10111;
100;
0101 0;
10011;
cleer:
nať ) :
IȚut•Icd.A' :cd.B•:cd.C'
:cd.D' :cd.E' :cd.F' :cd.G' ;cd.H' :cd. I
' :cd.0' ' •
lor
output(i
end
for J- l: 2
eise
test-tcd.K' :cd.Ľ
net-newp(aw. 10, ' M';cd.N'
hardl im' ) : :cd.0' •
net. tra i npararn.
net. epochs-1000 •
trainparam.goal-0 •
net-trai net. i nput.
output) ;
Y-sim(net.test);
Perceptron Networks 73
1-0.
end
end
Output
TRAINC, Epoch 0/1000
TRAINC. Epoch 25/1000
TRAINC. Epoch 50/1000
TRAINC. Epoch 54/1000
TRAINC. Performance goal met.
Test Pattern 1 is Recognisedas 0
Test Pattern 2 is Not Recognised
Test Pattern 3 is Recognisedas 2
Test Pattern 4 is Recognisedas 3
Test Pattern 5 is Recognisedas 4
1 Performanceis 0, Goal is O
0.9
0.8
8 0.7
0.6
8 0.5
2 0.4
0.3
02
0.1
o 5 10 15 20 25 30 35 40 45 50
54 Epochs
TrainingCurve
Intnxiuction to Neural
Example 4.' With a suitable cxantple demonstrate the pcrccptron learning law with its d
using MATLAB. Give the output in graphical form ecision
regions
Solution lhe following example demonstrates the pcrccptron learning law.
Program
clear
p S: dimensionality of the augmentedinput space
N SO. numberof travvng patterns - size of the training epoch
PARTI • Generationof the training and validation sets.
nn round(
XP= X(pr.
Z projection of the weightvector
co = cl = find(D==1):
Z co and cl are vectors of pointers to input patterns X
Z belonging to the class 0 or 1, respectively.
figure(l). cIf reset
'o', )(p(l,cl), Xp(2,cl), 'x')
Z The input patterns are plotted on the selected projection
Z plane. Patterns belongingto the class 0, or 1 are marked
Z with 'o' or 'x' respectively
axis(axis), hold on
Z The axes and the contentsof the current plot are frozen
Z Superimposition of the projection of the separation
plane on the
Z plot. Theprojection is a straight line. Fourpoints
lying onthis
Z line are foundfromthe line equation wp. x -0
S= +wp(3))•
LJ. [L grid, drawnow
% PART 2: Learning
eta = 0.5; %The training gain.
wh = 2*rand(1,p)-1:
Pemeptron Networks 75
Randominitialisation of the weight vector with
t fromthe range ( •1. •1) An exampleot an initial
value;
vector fol lows
projectlon of the initial decision planewhichis
orthogonal
to wh is plotted as previously
- projection of the weightvector
wht-
-0.4078 0.8716 -0.0416 0.2684 0.0126
10 6 6 4 6 3 4 4 4 2 o o
Nctuv»rk.s
Introductionto Neural
76
0.4
0.2
0.2
0.4 oo o
-0.6 O
-0.8
0.5 1
-0.5
Example 4.8 With a suitable example simulate the perceptron learning network and
anes. Plot the points assumed in the respective quadrants using different symbols for identification.
Solution Plot the elements as square in the first quadrant, as star in the second quadrant, as
third quadrant, as circle in the fourth quadrant. Based on the learning rule draw the decision boundaries.
Program
-0.05]' : p12-[O.05 :
til-t3:t12-t4:
P13-[-10.05]' 1]' :
t 13-t5:t14-t6:
-0.05)' :
Epoch 0/20
3/20
W INC. Per formance goal met
Figure No. 1
fue kdÜ Ylew Insert 1001s %ndow Help
loci: Endo.
Plot of the Given Vectors Plot of Input Pattems with Decision Boundaries
Figure No •r With T kAl NC
tue »ew loots
PeHormmc:2
is O,God is O
e 0.6
pet Boo•üares
to Neurol
111
Input vectors
Noisy vectors
Solution The input vectors and the noisy vectors are stored ina mat file, say class.mat, and the requireddata
is taken from the file. Here a subfunction called charplot.m is used. The MATLAB program for this is given
below.
Program
ZPerceptronfor patternclassification
clear:
clc•.
ZGet the data from file
data-open( 'class .mat' ) ;
x-data . s: Zinput pattern
t-data . t: ZTarget
ts-data. ts ; ZTesting pattern
n-15:
theta-0:
tP10t for Input Pattern
f' gure( I ) :
end
end
55 0 25]):
title( ' Input Pattern for Training') ;
con=l ;
epoch=0 :
while con
con=0:
for
for j=l:m
for i=l:n
if yin(j)>theta
end
if yin(j) <=theta
&
if yin(j)<-theta
if y(l.
w-w:b-b:
con-l•
for j-l:m
for i-l:n
end
end
82 Introduction to Neural Networks
epoch-epoch*
l,
end
(hsp( 'Numberof Epochs: ) ;
disp(epoch):
tTest1nqthe networkwith test pattern
XPlot for test pattern
fngure(2)•.
for J-1:4
end
end
55 0 251);
title( 'Noisy Input Pattern for Testing' ) ;
for 1-1:8
for
for
end
if yin(j)>theta
end
if yin(j) <=theta
&
end
if yin(j)<-theta
end
for i-1:8
end
end
XPlot for test outputpattern
figure(3);
for i-1:2
for J-1•.4
83
Perceptron Networks
k-k+l:
end
end
55 0 25));
fied OutputPattern' ) :
title( 'Classi
Subprogram used :
.ys. row.col )
functioncharplot(x.xs
for VI : row
for
end
end
for
for
plot(j+xs-l.ys-i+l.'r'):
hold on
else
hold on
end
end
end
Output
Numberof Epochs
10
Training
Noisy Input Pattern used for
Pitn
15
10
to
ReviewQuestions
4.1 What are the three layers in the original perceptron?
4.2 Briefly discuss on the learning rule of a perception network.
4.3 Explain the working of the perceptron net.
4.4 What is the activation function used in the perception network?
4.5 Explain the architecture of the perceptron net used for pattern classification.
4.6 State the perceptron learning rule convergence theorem.
4.7 Explain the algorithm used for training the perceptron net.
4.8 What are the stopping conditions used to stop the progress of the training algorithm?
4.9 How is perceptron net used in the aspect of linear separability?
4.10 Compare perceptron and Hebb net.
4.11 State the application algorithm used in perceptron net.
4.12 Write the perceptron training algorithm for several output classes.
4.13 Give a brief note on multilayer perceptrons.
Exercise Problems
4.14 Form a perceptronnet for OR function with binary input and output. Compare it with the
results obtained using bipolar input and targets.