Additional Flashcards
What are the parameters in a convolutional layer?
The parameters in a convolutional layer are the weights of the filters (kernels) and the biases. Each filter has weights corresponding to its size and the number of input channels, plus a single bias term.
How do you calculate the number of parameters in a convolutional layer?
What does the NHWC format represent in TensorFlow?
NHWC format in TensorFlow stands for:
N: Batch size
H: Height of the image
W: Width of the image
C: Number of channels
What does the NCHW format represent in PyTorch?
NCHW format in PyTorch stands for:
N: Batch size
C: Number of channels
H: Height of the image
W: Width of the image
How do you calculate the output dimensions of a convolutional layer?
What is the shape of an input tensor in TensorFlow with NHWC format for a batch of 16 RGB images of size 64x64?
The shape is
[16,64,64,3].
What is the shape of an input tensor in PyTorch with NCHW format for a batch of 16 RGB images of size 64x64?
The shape is
[16,3,64,64].
If a convolutional layer has 10 filters of size 5x5 and the input has 3 channels, how many parameters does the layer have?
The number of parameters is:
(5×5×3+1)×10=(75+1)×10=760
In a convolution operation, what happens when the filter slides over the input image?
The filter performs a dot product between its weights and the corresponding region of the input image, summing the contributions from all input channels, and adds a bias term to produce a single value in the output feature map.
Describe the output tensor shape after applying 8 filters of size 3x3 with a stride of 1 and no padding to a batch of 2 RGB images of size 32x32 in TensorFlow (NHWC format).
The output tensor shape will be
[2,30,30,8], assuming the height and width are reduced by 2 (32 - 3 + 1).
Describe the output tensor shape after applying 8 filters of size 3x3 with a stride of 1 and no padding to a batch of 2 RGB images of size 32x32 in PyTorch (NCHW format).
The output tensor shape will be
[2,8,30,30], assuming the height and width are reduced by 2 (32 - 3 + 1).
What is the purpose of padding in convolutional layers?
Padding is used to control the spatial dimensions of the output feature map. It adds extra borders to the input image, allowing the filter to fully cover the image borders, and helps maintain the input size.
Explain the difference between valid and same padding in convolutional layers.
Valid padding means no padding is added, and the filter only slides within the boundaries of the input image, reducing the spatial dimensions. Same padding adds zero-padding such that the output dimensions are the same as the input dimensions.
What is the role of stride in convolutional layers?
Stride controls the step size with which the filter moves over the input image. A stride of 1 means the filter moves one pixel at a time, while a stride greater than 1 means the filter skips pixels, reducing the output dimensions.
Calculate the output dimensions for an input of size 64x64 with 3 channels, using a filter of size 5x5, stride 1, and valid padding.