Loading...
Determine the padding P required to keep the output size equal to the input size (assuming stride S=1).
To maintain spatial dimensions (O=I) with stride 1, we solve:
I=I−F+2P+1
This gives us: P=2F−1
This is called "same" padding because the output has the same spatial dimensions as the input.
Write a function calculate_same_padding(filter_size) returning the integer padding amount. Assume the filter size is always odd.
Return an integer representing the padding needed for "same" convolution.
filter_size=5
2
2P = F - 1 → 2P = 4 → P = 2