Week6 2
Week6 2
“upper-left
beak” detector
“middle beak”
detector
Translation Invariance
* *
A CNN trained on facial recognition data may have biased performance across different
ethnicities, performing better for some groups than others, leading to fairness concerns.
Article: https://www.nytimes.com/2018/02/09/technology/facial-recognition-race-artificial-intelligence.html
A convolutional layer
• A CNN is a neural network with
some convolutional layers (and
some other layers).
• A convolutional layer has several
filters (Kernels) that do
convolutional operations.
• Sliding the filter over the input
image and computing the dot
product at every position, the
network learns to identify features
such as edges, shapes, and
Filter /Kernels textures, which are crucial for
understanding the content of the
image.
• Convolution operation is a
mathematical process that preserves
the spatial relationship between
pixels
Convolution in CNN
Filters contain parameters that are learned
during training
1 -1 -1
1 0 0 0 0 1 -1 1 -1 Filter 1
0 1 0 0 1 0 -1 -1 1
0 0 1 1 0 0
1 0 0 0 1 0
0 1 0 0 1 0 Each filter detects a
small pattern (3 x 3).
0 0 1 0 1 0
6 x 6 image
Convolution is performed on the input data using filter/kernel to
produce a feature map
Convolution : (Its sometimes easy to understand
visually)
Convolution : (Its sometimes easy to understand
visually)
......
Convolution in CNN
0 0 1 0 1 0 -1 -1 1
6 x 6 image
Each filter detects a small
pattern (3 x 3).
(h- f+1) x (w-f+1) x 2
h x w x 1 image f x f x 2 filter
Convolution in CNN
0 -1 1
Filter n
-1 0 -1
1 0 0 0 0 1 0 -2 1
.. ..
0 1 0 0 1 0 . .
0 0 1 1 0 0
1 0 0 0 1 0
∗ 0 -1 1
Filter 2
-1 0 -1
0 1 0 0 1 0 1-1 -1
-1 -11 Filter 1
0 0 1 0 1 0 -1 1 -1
6 x 6 image -1 -1 1
Each filter detects a small
pattern (3 x 3).
(h- f+1) x (w-f+1) x (nf)
h x w x nc image f x f x nf filter Output
How it works on colored images: RGB 3
channels
RGB image 1 0 0 0 0 1
0 0 0 0 0 1
0 1 0 0 10 0 1
0 1 0 0 1 0 -1 0 -1
0 0 1 10 0 01 0 1 -1 -1
0 0 1 1 0 0 -1 0 -1
1 0 0 01 1 0 0
1 0 0 0 1 0 ∗ -1 1
-1
-1
0 -1
0 1 0 0 10 01 0 -1 -1 1
0 1 0 0 1 0
0 0 11 0 10 01 0
0 0 1 0 1 0
0 0 1 0 1 0
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
Filters Sobel or Edge detector
Filters Sobel or Edge detector
Filters Sobel or Edge detector
detecting Vertical edges.
Filters Sobel or Edge detector
detecting horizontal edges.
Convolution Calculation with 1 Filter
-1 0 1 Filter Output
-1 0 1 0 30 30 0
-1 0 1 0 30 30 0
0 30 30 0
0 0 0 10 10 10 𝑜𝑢𝑡𝑝𝑢𝑡 0,0
0 ∗ −1 + 0∗0+0∗1+ 0 ∗ −1 + 0∗0+0∗1+ 0 ∗ −1
0 0 0 10 10 10 + 0∗0+0∗1
=0
0 0 0 10 10 10
0 0 0 10 10 10 𝑜𝑢𝑡𝑝𝑢𝑡 0,1
0 ∗ −1 + 0∗0+30∗1+ 0 ∗ −1 + 0∗0+30∗1+ 0 ∗ −1 + 0∗0+30∗1
0 0 0 10 10 10 =30
5 x 5 image