Professional Documents
Culture Documents
DeepLearning.AI makes these slides available for educational purposes. You may not use or distribute
these slides for commercial purposes. You may make copies of these slides and use or distribute them for
educational purposes as long as you cite DeepLearning.AI as the source of the slides.
Computer vision
deeplearning.ai
Computer Vision Problems
Image Classification Neural Style Transfer
Cat? (0/1)
64x64
Object detection
Andrew Ng
Deep Learning on large images
Cat? (0/1)
64x64
!"
!#
⋮ ⋮ ⋮ %&
!$
Andrew Ng
Convolutional
Neural Networks
Edge detection
deeplearning.ai
example
Computer Vision Problem
vertical edges
Andrew Ng
Vertical edge detection
10 10 10 0 0 0
10 10 10 0 0 0 0 30 30 0
1 0 -1
10 10 10 0 0 0 0 30 30 0
∗ 1 0 -1 =
10 10 10 0 0 0 0 30 30 0
1 0 -1
10 10 10 0 0 0 0 30 30 0
10 10 10 0 0 0
∗
Andrew Ng
Convolutional
Neural Networks
More edge
deeplearning.ai
detection
Vertical edge detection examples
10 10 10 0 0 0
10 10 10 0 0 0 0 30 30 0
1 0 -1
10 10 10 0 0 0 0 30 30 0
10 10 10 0 0 0
∗ 1 0 -1 =
0 30 30 0
1 0 -1
10 10 10 0 0 0 0 30 30 0
10 10 10 0 0 0
0 0 0 10 10 10
0 0 0 10 10 10 0 -30 -30 0
1 0 -1
0 0 0 10 10 10 0 -30 -30 0
0 0 0 10 10 10
∗ 1 0 -1 =
0 -30 -30 0
1 0 -1
0 0 0 10 10 10 0 -30 -30 0
0 0 0 10 10 10
Andrew Ng
Vertical and Horizontal Edge Detection
1 0 -1 1 1 1
1 0 -1 0 0 0
1 0 -1 -1 -1 -1
Vertical Horizontal
10 10 10 0 0 0
10 10 10 0 0 0 0 0 0 0
1 1 1
10 10 10 0 0 0 30 10 -10 -30
∗ 0 0 0 =
0 0 0 10 10 10 30 10 -10 -30
-1 -1 -1
0 0 0 10 10 10 0 0 0 0
0 0 0 10 10 10
Andrew Ng
Learning to detect edges
1 0 -1
1 0 -1
1 0 -1
3 0 1 2 7 4
1 5 8 9 3 1
#$ #% #&
2 7 2 5 1 3
#' #( #)
0 1 3 1 7 8
#* #+ #,
4 2 1 6 2 8
2 4 5 2 3 9
Andrew Ng
Convolutional
Neural Networks
Padding
deeplearning.ai
Padding
∗ =
Andrew Ng
Valid and Same convolutions
“Valid”:
Andrew Ng
Convolutional
Neural Networks
Strided
deeplearning.ai
convolutions
Strided convolution
2 3 3 4 7 43 4 4 6 34 2 4 9 4
6 1 6 0 9 21 8 0 7 12 4 0 3 2
3 -13 4 40 8 -143 3 40 8 -134 9 40 7 43 3 4 4
7 1 8 0 3 21 6 0 6 12 3 0 4 2 ∗ 1 0 2 =
4 -13 2 04 1 -134 8 40 3 -134 4 40 6 43 -1 0 3
3 1 2 0 4 12 1 0 9 12 8 0 3 2
0 -1 1 0 3 -13 9 0 2 -13 1 0 4 3
Andrew Ng
Summary of convolutions
padding p stride s
'()* +, '()* +,
+1 × +1
- -
Andrew Ng
Technical note on cross-correlation vs.
convolution
Convolution in math textbook:
2 3 7 4 6 2
6 6 9 8 7 4
3 4 5
3 4 8 3 8 9
∗ 1 0 2
7 8 3 6 6 3
-1 9 7
4 2 1 8 3 4
3 2 4 1 9 8
Andrew Ng
Convolutional
Neural Networks
Convolutions over
deeplearning.ai
volumes
Convolutions on RGB images
Andrew Ng
Convolutions on RGB image
∗ =
4x4
Andrew Ng
Multiple filters
∗ =
3x3x3 4x4
6x6x3 ∗ =
3x3x3
4x4
Andrew Ng
Convolutional
Neural Networks
One layer of a
deeplearning.ai
convolutional
network
Example of a layer
∗
3x3x3
6x6x3
∗
3x3x3
Andrew Ng
Number of parameters in one layer
Andrew Ng
Summary of notation
If layer l is a convolution layer:
#
" = filter size Input:
$ # = padding Output:
#
% = stride
#
&' = number of filters
Each filter is:
Activations:
Weights:
bias:
Andrew Ng
Convolutional
Neural Networks
A simple convolution
deeplearning.ai
network example
Example ConvNet
Andrew Ng
Types of layer in a convolutional network:
- Convolution
- Pooling
- Fully connected
Andrew Ng
Convolutional
Neural Networks
Pooling layers
deeplearning.ai
Pooling layer: Max pooling
1 3 2 1
2 9 1 1
1 3 2 3
5 6 1 2
Andrew Ng
Pooling layer: Max pooling
1 3 2 1 3
2 9 1 1 5
1 3 2 3 2
8 3 5 1 0
5 6 1 2 9
Andrew Ng
Pooling layer: Average pooling
1 3 2 1
2 9 1 1
1 4 2 3
5 6 1 2
Andrew Ng
Summary of pooling
Hyperparameters:
f : filter size
s : stride
Max or average pooling
Andrew Ng
Convolutional
Neural Networks
Convolutional neural
deeplearning.ai
network example
Neural network example
Andrew Ng
608
3216
48120
10164
850
Convolutional
Neural Networks
Why convolutions?
deeplearning.ai
Why convolutions
Andrew Ng
Why convolutions
10 10 10 0 0 0
10 10 10 0 0 0 0 30 30 0
1 0 -1
10 10 10 0 0 0 0 30 30 0
10 10 10 0 0 0
∗ 1 0 -1 =
0 30 30 0
1 0 -1
10 10 10 0 0 0 0 30 30 0
10 10 10 0 0 0
(1
+
&
Cost , = + - ℒ((1 . , ( . )
./&
Andrew Ng