what is the behavior of SAME padding when stride is greater than 1?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
SAME padding is often misinterpreted as “output size stays the same,” but that is only true in limited cases such as stride one with compatible kernels. When stride is greater than one, output still shrinks due to downsampling. SAME mainly controls how padding is chosen so coverage remains centered and edge loss is controlled.
Core Output Rule
For one spatial dimension in TensorFlow-style semantics:
So with input size 10 and stride 2, output is ceil(10/2)=5. That is smaller than input, even though padding mode is SAME.
This is the first key point: SAME does not cancel downsampling introduced by stride.
How Padding Is Computed
Padding is computed to ensure convolution windows can cover input consistently for the target output size.
Conceptual formula:
That padding is split across both sides. If pad_total is odd, one side gets one extra pad element.
This asymmetry is normal and can affect alignment when merging branches.
Numeric Example
Suppose input length 10, kernel 3, stride 2:
output = ceil(10/2) = 5pad_total = (5 - 1) * 2 + 3 - 10 = 1
So one pad element is needed in total. Framework places it around the boundaries according to implementation rules.
This allows all five output positions while keeping effective sampling centered.
TensorFlow Verification
SAME usually gives 5x5 spatial output in this case, while VALID often gives smaller dimensions because it adds no padding.
Why This Matters in Model Design
Misunderstanding SAME can cause shape mismatches in:
- Skip connections.
- U-Net style concatenation paths.
- Residual projections.
- Multi-branch feature fusion.
Always compute expected tensor sizes explicitly when mixing stride and different padding modes.
Odd Dimensions and Alignment Issues
When input dimensions are odd and stride exceeds one, asymmetric padding becomes more common. This can create off-by-one differences between branches that otherwise seem equivalent.
Practical handling:
- Log intermediate shapes.
- Use explicit crop or pad alignment layers when needed.
- Keep architecture diagrams synchronized with actual shape math.
These steps save significant debugging time.
Cross-Framework Caution
Different frameworks may use similar names but differ in boundary details. When converting models between ecosystems, validate layer outputs numerically and dimensionally rather than assuming label equivalence.
For conversion workflows:
- Compare each layer output shape.
- Compare a few deterministic sample outputs.
- Adjust padding or crop operations explicitly if needed.
Practical Rule of Thumb
Remember this compact rule:
- Stride controls downsampling rate.
SAMEcontrols padding policy, not output-preservation guarantee for stride above one.
If you need same-size output with stride above one, you likely need additional upsampling or architectural changes.
Keep this rule visible in model design docs to avoid repeated shape-debug cycles during architecture reviews and framework migrations.
Common Pitfalls
- Assuming
SAMEmeans identity-sized output for every stride value. - Ignoring asymmetric padding when combining multi-branch tensors.
- Mixing
SAMEandVALIDin residual paths without shape checks. - Porting models across frameworks without validating boundary behavior.
- Debugging training metrics before confirming tensor shape expectations.
Summary
- With stride above one,
SAMEstill reduces spatial dimensions. - Output follows a ceil-based stride rule.
- Padding is computed to preserve coverage, not to prevent downsampling.
- Asymmetric edge padding can appear, especially with odd dimensions.
- Explicit shape verification is essential in complex CNN architectures.

