NY Perceptron Notes
NY Perceptron Notes
Dr. N. YADAIAH
Professor of EEE
Department of Electrical & Electronics Engineering
JNTUH College of Engineering, Hyderabad
[email protected]
Perceptrons
• Perceptron is one of the earliest models of artificial neuron.
• It was proposed by Rosenblatt in 1958.
• It is a single layer neural network whose weights can be trained
to produce a correct target vector when presented with the
corresponding input vector
• The training technique used is called the Perceptron learning
rule.
• The Perceptron generated great interest due to its ability to
generalize from its training vectors and work with randomly
distributed connections.
• Perceptrons are especially suited for problems in pattern
classification.
1
Single layer Neural Networks
Perceptrons
Linear separability
A set of (2D) patterns (x1, x2) of two classes is linearly
separable if there exists a line on the (x1, x2) plane
w0 + w1 x1 + w2 x2 = 0
Separates all patterns of one class from the other class
A perceptron can be built with
3 input x0 = 1, x1, x2 with weights w0, w1, w2
n dimensional patterns (x1,…, xn)
Hyperplane w0 + w1 x1 + w2 x2 +…+ wn xn = 0 dividing
the space into two regions
Can we get the weights from a set of sample patterns?
If the problem is linearly separable, then YES (by
perceptron learning)
28-12-2022 Dr. N. Yadaiah, JNTU 3
LINEAR SEPARABILITY
2
Single layer Neural Networks
Perceptron Model
X0
x1 w1
n
net w i x i net Output
w2 f(.)
i 0 x2 o
O f net Hard
wn limiter
Inputs
3
Single layer Neural Networks
w
i 0
i xi 0 Class C1
x1
Class C2
Fig. 3.2 Illustration of the hyper plane (in this example, a straight line)
as decision boundary for a two dimensional, two-class patron classification problem.
For the Perceptron to function properly, the two classes C1 and C2 must be linearly
separable. Decision boundary
Cla Cla
Cla ss Cla ss
ss C2 ss
C2
C1 C1
(a) (b)
Fig (a) A pair of linearly separable patterns
(b) A pair of nonlinearly separable patterns.
In Fig.3.3(a), the two classes C1 and C2 are sufficiently separated from each other
to draw a hyper plane (in this it is a straight line) as the decision boundary.
4
Single layer Neural Networks
Assume that the input variables originate from two linearly separable classes.
Let æ1 be the subset of training vectors X1(1), X1(2), . , that belongs to class C1
æ2 be the subset of training vectors X2(1), X2(2), . , that belong to class C2.
Given the sets of vectors æ1 and æ2 to train the classifier, the training
process involves the adjustment of the W in such a way that the two
classes C1 and C2 are linearly separable. That is, there exists a weight
vector W such that we may write,
WX 0 for every input vector X belonging to class C1
WX 0 for every input vector X belonging to class C 2
where the learning rule parameter α controls the adjustment applied to the weight vector.
5
Single layer Neural Networks
Learning Algorithm
Step 1: Set learning rate (0<η≤1)
Step 2: Initialize the weights and bias at small random values.
Step 3: Set p←1, where p indicates the pth input vector presented.
Algorithm continued..
O p f net p
where, activation function is f net p
For bipolar binary activation function
1 if net p
o p f (net p )
1 if net p
For unipolar binary activation function
1 if net p
o p f (net p )
0 otherwise
6
Single layer Neural Networks
Algorithm continued..
7
Single layer Neural Networks
For input 1:
Let us consider the input, X1 = [0,0] with target, t1=0.
Step 4: Compute the net input to the Perceptron, using equation
2
net1 w i0 x 1i b 0 0.1 0 0.3 0 0
i 1
For input 2:
The steps 4 and 5 are repeated for the next input, X2 = [0, 1] with target, t2=1.
The net input obtained as
2
net 2 w 1i x i2 b1 0.1 0 0.3 1 0.3
i 1
8
Single layer Neural Networks
For input 3:
Repeat steps 4 and 5 for the next input, x3 = [1,0] with target, t3=1.
Compute the net input to the Perceptron and output
2
net3 w 2i x 3i b 2 0.1 1 0.3 0 0.1
i 1
o3= f(0.1) = 0
The output is not same as target, t2 = 1, the weights are updated using the equation (3.14)
The weights and bias are updated
w13 w12 (t3 oo ) x13 0.1 0.1 (1 0) 1 0.2
For input 4:
Repeat steps 4 and 5 for the next input, x4 = [1,1] with target, t3=1.
Compute the net input to the Perceptron and output
2
net 4 w 3i x i4 b 3 0.2 1 0.3 1 0.5
i 1
9
Single layer Neural Networks
Results 0.5
0.45
0.4
1 0.35
0.9 0.3
Error
0.8 0.25
0.7 0.2
0.6 0.15
Error
0.5 0.1
0.4 0.05
0.3 0
1 2 3 4 5 6 7 8 9 10
0.2 Number of epochs
0.1
0
1 2 3 4 5 6 7 8 9 10
Number of epochs
Fig. 3.5 The Error profile during the training of
Fig. 3.4 The Error profile during the training of Perceptron to learn input-output relation of
Perceptron to learn input-output relation of OR AND gate
gate
2.5
2
Error
1.5
0.5
0 5 10 15 20 25 30 35 40 45 50
Number of epochs
10
Single layer Neural Networks
11
Single layer Neural Networks
12
Single layer Neural Networks
13
Single layer Neural Networks
14
Single layer Neural Networks
.
E
wn
15
Single layer Neural Networks
16
Single layer Neural Networks
This theorem states that the Perceptron learning law converges to a final set of
weight values in a finite number of steps, if the classes are linear separable.
Proposition: If the sets P and N are finite and linearly separable, the Perceptron
Learning algorithm updates the weight vector wt in a finite number of times.
17
Single layer Neural Networks
18
Single layer Neural Networks
19
Single layer Neural Networks
The right hand side term grows proportionally to t and since 0 ; it can
become arbitrarily large. However, since cos 1 ; t must be bounded by a
1
maximum value t 2 .
The number of corrections to the weight vector must be finite.
Limitations of Perceptron
There are limitations to the capabilities of Perceptron however.
They will learn the solution, if there is a solution to be found.
First, the output values of a Perceptron can take on only one of
two values (True or False).
Second, Perceptron can only classify linearly separable sets of
vectors. If a straight line or plane can be drawn to separate the
input vectors into their correct categories, the input vectors are
linearly separable and the Perceptron will find the solution.
If the vectors are not linearly separable learning will never
reach a point where all vectors are classified properly.
The most famous example of the Perception’s inability to solve
problems with linearly non-separable vectors is the boolean XOR
realization.
20
Single layer Neural Networks
THANK YOU
21