Lecture # 4-1 Convolutional Neural Networks
Lecture # 4-1 Convolutional Neural Networks
AI-4009 Generative AI
1 4 0.98
1 W x + b a
-2
[ ] [ ] +¿ ¿[ ]
1 −2 1 0 .98
-1 -2 0.12 𝜎
−1 1 (−×1 1 ) 0.12
-1
1
[ ]4
−2
1
x1 …… y1
x 2 W1 W2 ……
WL y2
b1 b2 bL
……
……
……
……
……
xN x a1 a2…… y yM
y ¿ 𝑓 x( )
¿ WL … 𝜎
𝜎
W2 𝜎 b)
+ ( + b2 …
) + bL
1
x(
W1 ( )
j 1
0.05 ≈0
z3 -3
3
e e z3
y3 e z3
e
zj
3 j 1
e
zj
j 1
Shallow NN Deep NN
• #Layer
• Representation
……
x1 x2 …… xN
input
09/09/2024 Presented
Slide by LeeDr.– Deep
credit: Hung-yi AKHTAR JAMIL
Learning Tutorial 6
Introduction to Convolutional Neural Networks
Bedroom
64 Kitchen
64
12
25
25
51
51
51
51
12
25
21
51
8
6
6
2
2
8
5
2
2
Bathroom
Outdoor
Conv
layer
Max
Pool
Fully Connected
Layer
09/09/2024 Presented
Slide by VirDr.
credit: Param AKHTAR
Singh JAMIL
– Deep Learning 17
CNN architecture
Beak detector
A filter
Local Connectivity. Neurons will connect to only a local region of the input
volume.
The spatial extent of this connectivity is a hyperparameter called
the receptive field of the neuron (equivalently this is the filter size).
…
…
6 x 6 image
Each filter detects a
small pattern (3 x 3).
09/09/2024 Presented by Dr. AKHTAR JAMIL 24
Convolution
stride=1 1 -1 -1
-1 1 -1
1 0 0 0 0 1 Dot
0 1 0 0 1 0 product -1 -1 1
3 -1
0 0 1 1 0 0 Filter 1
1 0 0 0 1 0
0 1 0 0 1 0
0 0 1 0 1 0
6 x 6 image
6 x 6 image
6 x 6 image 3 -2 -2 -1
32 height
32 width
3 depth
5x5x3 filter
32
32
3
5x5x3 filter
32
32
3
1 number:
the result of taking a dot product between the
filter and a small 5x5x3 chunk of the image
32 (i.e. 5*5*3 = 75-dimensional dot product +
3 bias)
28
32 28
3 1
5x5x3 filter
32
28
32 28
3 consider a second, green filter 1
32
28
Convolution Layer
32 28
3 6
32 28 24
….
CONV CONV CONV
, , ,
ReLU ReLU ReLU
e.g. 6 e.g. 10
32 5x5x3 28 5x5x6 24
3 filters 6 filters 10
1 0 0 0 0 1 1 -1 -1 -1 1 -1
0 1 0 0 1 0 -1 1 -1 -1 1 -1
0 0 1 1 0 0 -1 -1 1 -1 1 -1
1 0 0 0 1 0
0 1 0 0 1 0
0 0 1 0 1 0
convolution
image
x1
1 0 0 0 0 1
0 1 0 0 1 0
x2
Fully- 0 0 1 1 0 0
1 0 0 0 1 0
connected
…
…
…
…
0 1 0 0 1 0
0 0 1 0 1 0
x36
09/09/2024 Presented by Dr. AKHTAR JAMIL 39
1 -1 -1 1 1
Filter 1
-1 1 -1 2 0
-1 -1 1 3 0
4 0 3
1 0 0 0 0 1 :
…
0 1 0 0 1 0 0
0 0 1 1 0 0 8 1
1 0 0 0 1 0
9 0
0 1 0 0 1 0
10: 0
0 0 1 0 1 0
…
13 0
6 x 6 image
14 0
fewer parameters! 15 1 Only connect to 9
16 1 inputs, not fully
connected
…
09/09/2024 Presented by Dr. AKHTAR JAMIL 40
1 -1 -1 1 1
-1 1 -1 :2 0
Filter 1
-1 -1 1 :3 0
:4 0 3
1 0 0 0 0 1 :
…
0 1 0 0 1 0 7 0
0 0 1 1 0 0 :8 1
1 0 0 0 1 0 :9 0 -1
0 1 0 0 1 0
10:: 0
0 0 1 0 1 0
…
13 0
6 x 6 image
:
14 0
Fewer parameters :
15 1
:
16 1 Shared weights
Even fewer parameters
:
…
09/09/2024 Presented by Dr. AKHTAR JAMIL 41
Visualize the Results
Fei-Fei Li & Justin Johnson & Serena Yeung April 18, 201
e7
u
L
rect 5 -
09/09/2024 45
preview:
Fei-Fei Li & Justin Johnson & Serena Yeung April 18, 201
e7
u
L
rect 5 -
Max Pooling
Can repeat
Fully Connected many
Feedforward network
Convolution times
Max Pooling
Flattened
09/09/2024 Presented by Dr. AKHTAR JAMIL 47
3
Flattening
0
1
3 0
-1 1 3
3 1 -1
0 3 Flattened
1 Fully Connected
Feedforward network
3
09/09/2024 Presented by Dr. AKHTAR JAMIL 48
Only modified the network structure and input
CNN in Keras format (vector -> 3-D tensor)
input
Convolution
1 -1 -1
-1 1 -1
-1 1 -1
-1 1 -1 … There are
-1 -1 1 25 3x3
-1 1 -1 … Max Pooling
filters.
Input_shape = ( 28 , 28 , 1)
3 -1 3 Max Pooling
-3 1
Input
1 x 28 x 28
Convolution
How many parameters for
each filter? 9 25 x 26 x 26
Max Pooling
25 x 13 x 13
Convolution
How many parameters 225=
for each filter? 50 x 11 x 11
25x9
Max Pooling
50 x 5 x 5
Input
1 x 28 x 28
Output Convolution
25 x 26 x 26
Fully connected Max Pooling
feedforward network
25 x 13 x 13
Convolution
50 x 11 x 11
Max Pooling
1250 50 x 5 x 5
Flattened
])
return model