Padding means adding extra pixels (usually zeros) around the edges of an image before applying convolution. It helps keep the output size larger or the same as the input.
Click to reveal answer
beginner
What does stride control in convolution?
Stride controls how many pixels the filter moves each step when sliding over the image. A stride of 1 moves one pixel at a time, stride 2 moves two pixels, making the output smaller.
Click to reveal answer
intermediate
What is the difference between 'valid' and 'same' padding in TensorFlow?
'Valid' padding means no padding is added, so the output is smaller than the input. 'Same' padding adds zeros so the output size stays the same as the input size.
Click to reveal answer
intermediate
How does increasing stride affect the output size?
Increasing stride makes the filter jump more pixels, so the output size becomes smaller because fewer positions are covered.
Click to reveal answer
beginner
Why might you use padding in a convolutional layer?
Padding helps preserve important edge information and controls output size. Without padding, edges get ignored and output shrinks quickly.
Click to reveal answer
What does 'same' padding do in a convolutional layer?
AKeeps output size the same as input size
BRemoves pixels from the input
CDoubles the output size
DAdds random noise to input
✗ Incorrect
'Same' padding adds zeros around the input so the output size matches the input size.
If stride is set to 2, what happens to the output size?
AOutput size becomes zero
BOutput size doubles
COutput size stays the same
DOutput size halves approximately
✗ Incorrect
Stride 2 moves the filter two pixels at a time, reducing output size roughly by half.
Which padding type means no padding is added?
ASame
BFull
CValid
DZero
✗ Incorrect
'Valid' padding means no padding, so output is smaller than input.
Why do we add padding in convolutional layers?
ATo keep edge information and control output size
BTo increase the number of filters
CTo speed up training
DTo reduce model size
✗ Incorrect
Padding preserves edges and helps keep output size as desired.
What happens if you use stride 1 and no padding?
AOutput size is larger than input
BOutput size is smaller than input
COutput size stays the same
DModel will not train
✗ Incorrect
Without padding and stride 1, output shrinks because filter can't slide over edges fully.
Explain in your own words what padding and stride do in a convolutional neural network.
Think about how the filter moves and what happens at image edges.
You got /4 concepts.
Describe the difference between 'valid' and 'same' padding and how they affect the output size.
Consider how zeros around the image change the convolution result.
You got /4 concepts.
Practice
(1/5)
1. What does padding do in a convolutional layer in TensorFlow?
easy
A. Changes the filter size
B. Adjusts the learning rate
C. Controls the number of filters
D. Adds extra space around the input edges
Solution
Step 1: Understand padding role
Padding adds pixels around the input image edges to control output size and preserve edge information.
Step 2: Compare options
Only Adds extra space around the input edges correctly describes padding as adding space around input edges.
Final Answer:
Adds extra space around the input edges -> Option D
Quick Check:
Padding = Adds space around input edges [OK]
Hint: Padding adds border space around input images [OK]
Common Mistakes:
Confusing padding with stride
Thinking padding changes filter size
Assuming padding controls learning rate
2. Which of the following is the correct way to specify stride of 2 in TensorFlow's Conv2D layer?
easy
A. strides=(2)
B. stride=(2)
C. strides=(2, 2)
D. stride=2
Solution
Step 1: Recall Conv2D stride syntax
TensorFlow Conv2D expects strides as a tuple for height and width, e.g., (2, 2).
Step 2: Check options
Only strides=(2, 2) uses the correct parameter name and tuple format.
Final Answer:
strides=(2, 2) -> Option C
Quick Check:
Stride syntax = strides=(2, 2) [OK]
Hint: Use tuple for strides in Conv2D: strides=(height, width) [OK]
Common Mistakes:
Using 'stride' instead of 'strides'
Passing a single integer instead of a tuple
Omitting parentheses around stride values
3. Given an input of size 28x28, a filter size of 3x3, stride of 2, and 'valid' padding, what is the output size after Conv2D?
medium
A. 13x13
B. 14x14
C. 15x15
D. 12x12
Solution
Step 1: Calculate output size formula for 'valid' padding