CNNs: Practice and Extra Details¶
Prof. Forrest Davis
- Work with your group
- Stop after finishing each section
Convolution Refresher: Benefits of Parameter Sharing¶
Question: Apply the following kernel to the input matrix with stride 1:
Kernel: $\left[\begin{array}{cc} 10 & 1\\ 0 & 2 \end{array}\right]$
input: $\left[\begin{array}{cccccc} 1 & 0 & 4 & 3 & 4 & 3\\ 3 & 4 & 3 & 1 & 0 & 2\\ 1 & 4 & 3 & 4 & 2 & 3\\ \end{array}\right]$
||
||
||
||
||
||
||
||
||
||
||
||
- Recall, last class I applied a simple edge detection algorithm which subtracting each pixel by the value to its left.
Question Give a 1D kernel that accomplishes this task
||
||
||
||
||
||
- Consider an image whose shape is 320 pixels by 280 pixels
Question: What is the shape of the output of this kernel with a stride of 1?
||
||
||
||
||
||
Question: Give a general expression for the shape of the output after applying a kernel
||
||
||
||
||
||
- Floating-point operations are any mathematical operation (e.g., +, *, -, /) or assignment involving floating-point numbers
- Ignoring assignment here, a matrix multiplication implementation of our edge detection operation applied to a image of shape 320 X 280 would require more than 16 billion floating-point operations
Question: How many floating-point operations does our convolution trick require (again ignoring assignment)?
||
||
||
||
||
||
Padding¶
- How do we prevent the reduction in image size caused by convolution (e.g., we lost one row and one column in our first example in the handout)?
Question: Try to come up with an approach that resolves this (and give the resultant convolution) for the example below
Stride: 2
Kernel: $\left[\begin{array}{cc} 1 & 2\\ 0 & 2 \end{array}\right]$
input: $\left[\begin{array}{cccc} 3 & 1 & 2 & 4 \\ 2 & 2 & 4 & 0 \\ 3 & 2 & 2 & 1 \\ 3 & 4 & 4 & 0 \\ \end{array}\right]$
||
||
||
||
||
||
||
||
||
||
||
||