Cnn-I
Cnn-I
Image Classification
Cat? (0/1)
Object detection
64x64x3
Text
detection
16 x 16 = 256
x1 256 inputs
x2
Total weights = W = 256 x 1000
…
…
x256 𝑥1
16 x 16 = 256
𝑥2
Ink → 1
No ink → 0 ⋮ ⋮ ⋮ 𝑦ො
𝑥𝑛
1000 1000
Dr. Hashim Yasin Applied Machine Learning (CS4104)
Why CNN
5
Image Classification
Cat? (0/1)
64x64x3
Image Classification
3M inputs
𝑥1
𝑥2
⋮ ⋮ ⋮ 𝑦ො
𝑥𝑛
1000x1000x3 1000 1000
= 3 million
Total weights = W = 3M x 1000
a b
g ( x, y ) = w(s, t ) f ( x + s, y + t )
s = − at = − b
At any point (𝑥, 𝑦), the response g(𝑥, 𝑦) of the
filter is the sum of product of filter coefficient
and the image pixels
g ( x, y ) = w(−1,−1) f ( x − 1, y − 1) +
w(−1,0) f ( x − 1, y ) + ...
w(0,0) f ( x, y ) + ...
w(1,1) f ( x + 1, y + 1)
Dr. Hashim Yasin Applied Machine Learning (CS4104)
g ( x, y ) = w(−1,−1) f ( x − 1, y − 1) +
w(−1,0) f ( x − 1, y ) + ...
Cross-correlation w(0,0) f ( x, y ) + ...
10 w(1,1) f ( x + 1, y + 1)
(x,y) (x,y)
Image point
Filter mask point
10 11 10 0 0 1 X X X X X X
9 10 11 1 0 1 X 10 X
10 9 10 0 2 1 X X
11 10 9 9 11 X X
10
9 10 11 9 99 11 H X X
10 9 9 11 10 10 1 X X X X X X
1 1
F 1 1 1 G
1/9
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
1
1
1
1
1
1
*
0
0
0
0
0
0
0
0
0
90
90
90
90
0
90
90
90
90
90
90
90
90
90
90
0
0
0
0
0
0
= 0
0
0
30
30
20
50
50
30
80
80
50
80
80
50
90
90
60
60
60
40
30
30
20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
𝑤 ∗ 𝑓 = g
Dr. Hashim Yasin Applied Machine Learning (CS4104)
Convolution Examples-Mean filtering
16
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
1
1
1
1
1
1
*
0
0
0
0
0
0
0
0
0
90
90
90
90
0
90
90
90
90
90
90
90
90
90
90
0
0
0
0
0
0
= 0
0
0
30
30
20
50
50
30
80
80
50
80
80
50
90
90
60
60
60
40
30
30
20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
𝑤 ∗ 𝑓 = g
Dr. Hashim Yasin Applied Machine Learning (CS4104)
Convolution Examples-Mean filtering
17
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
1
1
1
1
1
1
*
0
0
0
0
0
0
0
0
0
90
90
90
90
0
90
90
90
90
90
90
90
90
90
90
0
0
0
0
0
0
= 0
0
0
30
30
20
50
50
30
80
80
50
80
80
50
90
90
60
60
60
40
30
30
20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
𝑤 ∗ 𝑓 = g
Dr. Hashim Yasin Applied Machine Learning (CS4104)
Convolution Examples-Mean filtering
18
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
1
1
1
1
1
1
*
0
0
0
0
0
0
0
0
0
90
90
90
90
0
90
90
90
90
90
90
90
90
90
90
0
0
0
0
0
0
= 0
0
0
30
30
20
50
50
30
80
80
50
80
80
50
90
90
60
60
60
40
30
30
20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
𝑤 ∗ 𝑓 = g
Dr. Hashim Yasin Applied Machine Learning (CS4104)
Linear filters: examples
19
0 0 0
=
* 0
0
1
0
0
0
Source: D. Lowe
0 0 0
=
* 1
0
0
0
0
0
Source: D. Lowe
1 1 1
=
* 1
1
1
1
1
1
Source: D. Lowe
1
f f
2 2 2
= +
x y
Dr. Hashim Yasin Applied Machine Learning (CS4104)
Gradient Operator
25
1
M ( x, y ) = mag (f ) = [G + G ]
2
x
2
y
2
1
f f
2 2 2
= +
x y
commonly approx.
the magnitude
becomes nonlinear M ( x, y ) G x + G y
M ( x, y ) G x + G y
the weight value 2 is to achieve
smoothing by giving more
important to the center point
vertical edges
horizontal edges
Dr. Hashim Yasin Applied Machine Learning (CS4104)
CNN … Example
30