Professional Documents
Culture Documents
CSE 473 Pattern Recognition: Instructor: Dr. Md. Monirul Islam
CSE 473 Pattern Recognition: Instructor: Dr. Md. Monirul Islam
Pattern Recognition
Instructor:
Dr. Md. Monirul Islam
Linear Classifier
2
Learning a Linear Classifier
x2
w.x + w0 =0
wtx + w0 =0
x = [x1, x2]
w = [w1, w2]
x1
The Perceptron Algorithm
– Use training file to learn w
– Steps
– Initialize w
– Classify all training samples using current w
– Find new w using
w(t 1) w(t ) t x x
xY
4
Classification by a Trained
Perceptron
g(x)= w.x + w0
If g(x) > 0 : x ω1
x2 Otherwise : x ω2
wtx + w0 =0
x = [x1, x2]
w = [w1, w2]
x1
Variants of Perceptron Algorithm (1)
T
w (t ) x ( t ) 0
update
w (t 1) w (t ) x ( t ) ,
x ( t ) 1
T
w (t ) x ( t ) 0
w (t 1) w (t ) x ( t ) ,
x (t ) 2
w (t 1) w (t ) otherwise No Update
6
Variants of Perceptron Algorithm (2)
– It is pocket algorithm
7
Generalization of Perceptron Algorithm
for M- Class case
• Let M classes ω1, ω2, ω3, . . ., ωM,
• Let M linear discriminant functions, wi
8
Generalization of Perceptron Algorithm
for M- Class case
• Let M classes ω1, ω2, ω3, . . ., ωM,
• Let M linear discriminant functions, wi
• The object x is classified to ωi, if
9
Generalization of Perceptron Algorithm
for M- Class case
• The object x is classified to ωi, if
T T
[ wi wj ].x 0
10
Generalization of Perceptron Algorithm
for M- Class case
• The object x is classified to ωi, if
T T
[ wi wj ].x 0
can be written as
T T T T T T
[0 ,,0 , wi ,,0 , w j ,0 ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0 11
Generalization of Perceptron Algorithm
for M- Class case
T T T T T T
[0 ,,0 , wi ,,0 , w j ,0 ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0
12
Generalization of Perceptron Algorithm
for M- Class case
T T T T T T
[0 ,,0 , wi ,,0 , w j ,0 ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0
T T T T T T
[0 ,,0 , wi ,,0 , w j ,0 ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0
13
Generalization of Perceptron Algorithm
for M- Class case
T T T T T T
[0 ,,0 , wi ,,0 , w j ,0 ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0
T T T T T T
[0 ,,0 , wi ,,0 , w j ,0 ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0
14
Generalization of Perceptron Algorithm
for M- Class case
[ wiT wTj ].x 0
T T T T T T
[0 ,,0 , wi ,,0 , w j ,0 ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0
T T T T T T T
and xi , j [0 ,,0 , x ,,0 , x ,0 ]
16
Generalization of Perceptron Algorithm
for M- Class case
T T T T T
[ w1 , w2 , wi ,, w j , wM ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0
T T T T T T
Let, w [ w1 , w2 , wi ,, w j , wM ]
T T T T T T T
and xi , j [0 ,,0 , x ,,0 , x ,0 ]
i-th j-th
position position 17
Generalization of Perceptron Algorithm
for M- Class case
T T T T T
[ w1 , w2 , wi ,, w j , wM ].
T T T T T T T
[0 ,,0 , x ,,0 , x ,0 ] 0
T T T T T T
Let, w [ w1 , w2 , wi ,, w j , wM ]
T T T T T T T
and xi , j [0 ,,0 , x ,,0 , x ,0 ]
Then, the wT xi , j 0
condition is 18
Generalization of Perceptron Algorithm
for M- Class case
• For each training vector of class ωi, construct
T T T T T T T
xi , j [0 ,,0 , x ,,0 , x ,0 ]
ith location jth location
(l+1)M dimension
22
Kesler’s Algorithm: Testing
• Isolate each weight vector wiT from combined w
23
Sample Data for Sessional on
Perceptron Algorithms (Week 3 and 4)
Classes Features Samples
3 3 300
26
What to do?
• This instruction and data files (both linearly separable and non-
separable) will be uploaded to moodle as well
27
Convergence Proof of Perceptron
Algorithm
28
Convergence Proof of Perceptron
Algorithm
29
Convergence Proof of Perceptron
Algorithm
We know that w(t 1) w(t ) t x x
xY
Then,
30
Convergence Proof of Perceptron
Algorithm
31
Convergence Proof of Perceptron
Algorithm
However,
32
Convergence Proof of Perceptron
Algorithm
However,
Hence,
33
Convergence Proof of Perceptron
Algorithm
Now, define
and
Convergence Proof of Perceptron
Algorithm
Now, define
and
35
Convergence Proof of Perceptron
Algorithm
Now, define
and
We can write,
36
Convergence Proof of Perceptron
Algorithm
If we choose,
We can write,
37
Convergence Proof of Perceptron
Algorithm
Here, t2 2 t 2 0
How?
38
Convergence Proof of Perceptron
Algorithm
39
Convergence Proof of Perceptron
Algorithm
However,
40
Convergence Proof of Perceptron
Algorithm
However,
41
Convergence Proof of Perceptron
Algorithm
However, and
This means,
After some constant tine t0 the R. H. S. will be non-positive
Therefore,
42
Convergence Proof of Perceptron
Algorithm
is equivalent to
43