AIWS Practical 2:�Convolutional Neural Network (CNN)
5W 1H
5W 1H
5W 1H
Part 1:�What is CNN?
What is CNN?
Which diagram better describes the architecture of CNN?
What is CNN?
Which diagram better describes the architecture of CNN?
What is C?
Which diagram better describes the architecture of CNN?
What is Convolution?
Which diagram better describes the architecture of CNN?
Convolution
1*1 + 1*0 + 1*1 +
0*0 + 1*1 + 1*0 +
0*1 + 0+0 + 1*1 = 4
Convolution
Sum over element-wise multiplication
Convolution
Values of weights of the filter?
Convolution
Values of weights of the filter?
1, 0, 1,
0, 1, 0,
1, 0, 1
Convolution
Size of the filter?
Convolution
Size of the filter?
3*3?
Convolution
Size of the filter?
3*3*1 (height, width, depth)
Filter depth is easily overlooked.
Filter depth is easily overlooked.
How standard convolution calculation works along depth
a) 2D convolution for each input channel with 2D filters & add up
= b) element-wise product between input & 3D filters & add up
How standard convolution calculation works along depth
a) 2D convolution for each input channel with 2D filters & add up
How standard convolution calculation works along depth
b) element-wise product between input & 3D filters & add up
Summary: Part 1
1. CNN gets inputs & outputs with certain depth
2. Thus, filter (or kernel) should also have depth for the convolution, apart from the number of filter
3. Filter depth is same with input’s depth
4. Convolution is just sum of element-wise multiplication between corresponding (i.e., same position) weights of filter & input
Part 2:�Why CNN?
Part 2:�Why CNN (used for image)?
Black box
CNN vs ANN
What is the difference?
Convolution operation
Did you see this before?
Convolution operation
Similar vectors (or values) 🡺 Higher values
Convolution operation
Similar vectors (or values) 🡺 Higher values
Convolution operation
Similar vectors (or values) 🡺 Higher values
Convolution operation
Similar vectors (or values) 🡺 Higher values
CNN learns features
Similar vectors (or values) 🡺 Higher values
CNN learns features
CNN can learn features
🡺 So… What?
CNN learns features
CNN can learn features
🡺 In case of stationary data, like image, such features do not change by their position
Stationarity
CNN can learn features
🡺 In case of stationary data, like image, such features do not change by their position
🡺 We can use filter!!
Stationarity
We can use filter.
CNN learns features
CNN can learn features (in case of stationary data, like image)
Parameter sharing
Okay. Then why using filter is good?...
Parameter sharing
Okay. Then why using filter is good?...
= one parameter can see (or learn) the data much more times
Locality of pixel dependencies
Parameter sharing is not only efficient, but it also gives locality on information
Locality of pixel dependencies
In case of the image data, pixels in red region is irrelevant to those in blue region
Locality of pixel dependencies
Parameter sharing is not only efficient, but it also gives locality on information
Locality of pixel dependencies
Parameter sharing is not only efficient, but it also gives locality on information
Summary: Part 2
1. CNN can extract features, based on characteristic of convolution operation (cf. inner product)
2. A feature of image (or other stationary data) does not change along axis of time or location
3. Therefore, we can apply filter rather than using fully connected layer
4. Using filter results in 1) parameter sharing & 2) statistical efficiency
5. It also fits well in terms of locality of pixel dependencies, which is one of main characteristics of image data
Part 3:�How?
Build CNN model using Pytorch