Pattern Classifiers1
Pattern Classifiers1
Hebb Nets
• A single -layer feedforward neural net trained through the Hebb
learning is known as a Hebb net.
• The hebb learning rule is the training procedure for a Hebb net where
a net is trained to implement the logical AND function.
Hebb Rule
• The Hebb rule is one of the earliest learning rules forANNs. According
to this rule the weight adjustment is computed as
• ∆wi = xi*t
• where t is the target activation
• There are certain points to be kept in mind regarding the Hebb
learning rule.
• First, Hebb rule cannot learn when the target is 0.
• This is because the weight adjustment ∆wi becomes zero when t=0,
irrespective of the value of xi .
Hebb Rule
1 X0 W0
X1 Y
x1 W1 y_out= x1^x2
x2 X2 W2
Table: Training set for AND function
Input Patterns Output
X0 X1 X2 t
+1 1 1 1
+1 1 -1 -1
+1 -1 1 -1
+1 -1 -1 -1
Example:Realizing the logical AND function
through Hebb learning.
x1
x1
(-1 ,-1) (1,-1) (-1,-1) (1,-1)
x2= -x1-1 x 2= 0
x2 x2
x1 x1
x2=-x1+1 x2=-x1+1
( -1,-1) (1,-1) (-1,-1) (1,-1)
(c) After 3rd pattern (-1,1) (d) After 4th pattern (-1,-1)
Example:Realizing the logical AND function through
Hebb learning.
• After learning with the second pattern (1,-1) the situation is better.
• Only (-1,1) is still misclassified.
• This is corrected after training with the third pattern (-1,1).
• Now all the -1 producing patterns are i.e., (1,-1), (-1,1) and (-1,-1) are in
the same class and the remaining pattern (1,1) constitutes the other
class.
Structure of the Hebb net
1 x0
w0
x1 x1
w1
y
xi
xi wi y_out
xm
xm wm
Structure of the Hebb net
• It should be noted that the input unit X0 and the associated weight
w0 play the role of the bias.
• The activation X0 is always kept at 1.
• Hence, the expression for the adjustment of w0 becomes
wo(new)= w0(old)+1xy_out=w0(old)+y_out
Perceptrons
Perceptron Learning Rule
• Let us consider aimple ANN consisting of a single perceptron Y with
m+1 input units X0 ---------------Xm as shown in following fig.
• The corresponding weights of interconnection are w0---------wm.
• The bias is introduced as the weight w0 connected to the input X0
whose activation is fixed at 1.
• For the output unit , it is convenient to use the bipolar activation
function:
1, if y_in>0
y_out={ 0 , if y_in=0
-1, if y_in<0
Structure of a perceptron
1 x0
w0
x1 x1
w1
y
xi
xi wi y_out
xm
xm wm
Perceptron Learning Rule
• Now let X=(x0--------xm) be a trainng vector for which the output of the
perceptron is expected to be t,where t=1,0 or -1.
• The current combination of the weights is given by the weight vector
W= (w0----------wm ).
• If the perceptron produces the desire output , then the weights
w0-----wm need not be changed and they are to be kept unaltered.
• If, however , the perceptron misclassifies X negatively(meaning, it
erroneously produces -1 instead of the desired output +1) then the
weight should be appropriately increased.
Perceptron Learning Rule
Condition Action
1.The perceptron classifies the No change in the current set of
input pattern correctly(y_out=t) weights w0,w1-------,wm
2.The perceptron misclassifies the Increase each wi by ∆wi ,where ∆wi
input pattern negatively(y_out=-1, is proportional to xi for all
but t=+1)
i=0,1,-------m
3.The perceptron misclassifies the Decrease each wi by ∆wi ,where
input pattern positively(y_out=+1, ∆wi is proportional to xi for all
but t=-1)
i=0,1,-------m
Perceptron Learning Rule
x0 X0 w01 Y1 y_out1
w0n w0j
Yj
xi Xi wi1 wij y_out2
win
Xm wm1 wmj Yn y_outn
xm wmn
Input layer Output layer
Perceptron Learning Rule
• Using the matrix notation, the perceptron learning rule may now be written
as
∆W=ɳ*(t-y_out)*X ---------------------(1)
• Where ∆W and X are the vectors corresponding to the interconnection
weights and the inputs.
• ∆W=[∆w0,∆w1,---------------∆wm]
and X=[x0, x1,----------------xn]
• Equation 1 can be easily extended to a network of several perceptron at the
output layer.
• Such architecture is shown in above Fig of slide no 25.
Perceptron Learning Rule
• or Y_in T =WT*XT
• For such an ANN , the djustment ∆wij of the weight wij is given by
∆wij =ɳ*(tj -y_outj )*xi
• Let us assume the following matrix notations:
w01 w02 .... .... w0 n
w11 w12 ... ... w1n
∆W= ... ... ... ... ..
... ... ... ... ...
wm1 wm 2 ... ... wmn
Perceptron Learning Rule
[∆w]T =ɳ*[T-Y_out]T *X
Learning the logical AND function by a
perceptron
• Let us train a perceptron to realize the logical AND function.The training
patterns and the corresponding target outputs for the AND operation
where the input and the outputs are in bipolar form are given in
following table.The structure of the perceptron is same as showin in
following fig.Activation function for the output unit is:
1, if y_in>0
• y_out=g(y_in)={ 0, if y_in=0
-1, if y_in<0
Structure of a neural net to realize the
AND function
1 X0 W0
X1 Y
x1 W1 y_out= x1^x2
x2 X2 W2
Table: Training set for AND function
Input Patterns Output
X0 X1 X2 t
+1 1 1 1
+1 1 -1 -1
+1 -1 1 -1
+1 -1 -1 -1
Learning the logical AND function by a
perceptron
• The successive steps of computation with the first training pair are
given below.
i) Initialize weights: w0=w1=w2=0 and the learning rate ɳ=1
ii) For the training pair s:t=(1,1,1):(1) , compute the net input y_in
and the activation y_out :
y_in =w0*x0+w1*x1+w2*x2
= 0*1+0*1+0*1
=0
y_out=0
Learning the logical AND function by a perceptron
• We get the separating line as x2=-x1-1, which classifies the pattern (1,1) and (-1,-
1), correctly but misclassifies the patterns (-1,1) and (1,-1).
• Following fig represent the above condition.
• A trace of the remaining steps of the first epoch of the training (an epoch of
training consists of successive application of each and every training pair of the
training set for once ) are noted in following table.
• Hence the set of weights obtained at the end of the first epoch of training is (-1,
1,1) which represent the decession line
x2=-x1+1 .
• It can be easily verified that this line ( and the corresponding set of
weights)successfully realizes the AND function for all possible input combinations.
• Hence , the is no need of further training.
Learning the logical AND function by a
perceptron
x2
(-1,1) (1,1)
x1
y_in=
i 0
w i x i
Step 6: Compute the activation of the output unit using the following function.
Procedure for perceptron-Learning
1, if y_in >θ
y_out= { 0, if y_in -θ≤y_in≤θ
-1, if y_in <-θ
Step 7:If there is an error, i.e., y_out≠t, then adjust the weights as follows
wi(new)=wi(old)+n*t*xi
If, however, no error has occurred, the weights are kept unchanged.
Step 8: If there were no error, i.e., y_out=t, for the entire set of training
pairs,then stop, otherwise, go to step 3.
Any Question?
Thank You