Formulla
1.Output size after one convolutional layer:
2.Output size with padding and stride:
- Number of parameters in a convolutional layer:
- Same padding convolution output size:
7.Number of parameters in convolution:
8.Output size after multiple convolution layers:
9.Convolution followed by pooling output size:
10.Fully connected layer input size:
11.Stride and padding convolution output size:
12.3D Convolution output size:
13.Depthwise separable convolution parameters:
Depthwise Parameters
- Fully connected layer parameters:
- Dilated convolution output size:
Numericals
1.Given a 5x7 input matrix (m x n) and a 3x3 filter matrix (f x f), perform a valid convolution operation. Calculate the size of the output matrix.
Input details
:
Input matrix size (m x n): 5x7
Filter matrix size (f x f): 3x3
Padding: 0 (valid padding, meaning no padding is applied)
Stride: 1
Solution
:
Formula to calculate the output size:
Output width=n−f+1=7−3+1=5
So, the output matrix will be of size 3x5.
Explanation:
The convolution process involves sliding the 3x3 filter over the 5x7 input matrix. Since it's a valid convolution (no padding), the filter only fits entirely within the matrix a certain number of times based on the stride (which is 1 here). This results in an output matrix of size 3x5.
This is a typical example of performing convolution in a CNN with valid padding, where the output shrinks based on the size of the filter and stride.
2.Given a 7x9 input matrix (m x n) and a 3x3 filter matrix (f x f), perform a convolution operation with same padding and calculate the size of the output matrix.
Input detail
s:
Input matrix size (m x n): 7x9
Filter matrix size (f x f): 3x3
Padding: 1 (same padding)
Stride: 1
Solution
:
Formula to calculate the output size:
Explanation
:
The "same" padding ensures that the output matrix retains dimensions close to the input size by padding the input with a border of zeros.
After applying the 3x3 filter, the resulting output dimensions are 5x7, as calculated.
-
Calculate the output size of a convolutional layer:
Input size: 32x32
Filter size: 3x3
Padding: 0 (no padding)
Stride: 1
Solution
:
-
Calculate the output size of a convolutional layer with padding:
Input size: 28x28
Filter size: 5x5
Padding: 2
Stride: 1
Solution
:
**Calculate the output size with stride greater than **1:
Input size: 32x32
Filter size: 3x3
Padding: 0
Stride: 2
Solution:Max Pooling layer output size:
Input size: 16x16
Pool size: 2x2
Stride: 2
Solution
:
-
Average Pooling layer output size:
Input size: 14x14
Pool size: 2x2
Stride: 2
Solution
:
-
Output size with different stride:
Input size: 32x32
Filter size: 5x5
Padding: 0
Stride: 1
Solution
:
- Calculate convolution with same padding: Input size: 28x28 Filter size: 3x3 Padding: "same" (equivalent to padding = 1) Stride: 1 Solution:
-
Calculate convolution with valid padding:
Input size: 32x32
Filter size: 3x3
Padding: "valid" (no padding)
Stride: 1
Solution
:
-
Stride and padding combination:
Input size: 64x64
Filter size: 5x5
Padding: 2
Stride: 2
Solution
:
-
3D convolution (height, width, depth):
Input size: 28x28x3
Filter size: 3x3
Padding: 1
Stride: 1
Solution
:
-
Max Pooling for 3D input:
Input size: 32x32x3
Pool size: 2x2
Stride: 2
Solution
:
- Output size for convolution with non-square input: Input size: 64x32 Filter size: 5x5 Padding: 0 Stride: 2 Solution:
Output size:
- Calculate output with dilation: Input size: 32x32 Filter size: 3x3 Padding: 1 Stride: 1 Dilation: 2 Solution:
Output size:
- Depthwise convolution output: Input size: 64x64x3 Filter size: 3x3 Padding: 1 Stride: 1 Solution:
-
Calculate the output size of average pooling with padding:
Input size: 28x28
Pool size: 2x2
Padding: 1
Stride: 2
Solution
:
Output size:
Top comments (0)