CS5720 - Week 4
Slide 68 of 80

Stride and Padding

πŸƒβ€β™‚οΈ Stride

Stride determines how many pixels the filter moves at each step during convolution. It controls the spatial size of the output feature map.
Stride = 1 (Default)
Filter moves one pixel at a time. Preserves spatial resolution but requires more computation.
Stride = 2
Filter moves two pixels at a time. Reduces output size by approximately half in each dimension.
Benefits & Trade-offs
Higher stride = smaller output, faster computation, but potential information loss.
Output Size = ⌊(Input - Kernel + 2Γ—Padding) / StrideβŒ‹ + 1

πŸ›‘οΈ Padding

Padding adds extra pixels around the input borders to control the output size and preserve information at the edges.
No Padding (Valid)
No extra pixels added. Output size shrinks with each convolution layer.
Same Padding
Padding added to keep output size same as input (when stride=1).
Custom Padding
Specific number of pixels added. Usually filled with zeros (zero-padding).
Common Padding Values:

β€’ 0: No padding (valid convolution)
β€’ (k-1)/2: Same padding for kernel size k
β€’ Custom: Based on specific requirements

Interactive Stride & Padding Demonstration

Stride:
1
Padding:
0
Input with Padding
Convolution Process
Output Feature Map
Input: 7Γ—7, Kernel: 3Γ—3, Stride: 1, Padding: 0 β†’ Output: 5Γ—5
Prepared by Dr. Gorkem Kar