Padding to 0. Same vs Valid

The correction says that p=0 means valid conv while when applying the formula Andrew mentioned, it doesn’t make a difference to set p=0 or not. I mean p=0 still results in “same convolution”

From my understanding, the formula: (n + 2p - f / s) + 1 == (39 + 2*0 - 3 / 1) + 1 == (39 + 0 - 3 / 1) + 1 == (39 - 3 / 1) + 1 == (36 / 1) + 1 == 37.
So, how p=0 affects padding?

For same padding,

\begin{aligned} (n + 2p -f) / s + 1 &= n \Leftrightarrow \\ n + 2p - f &= (n - 1) * s \Leftrightarrow \\ p &= ((n - 1) * s + f - n) / 2. \end{aligned}

With your example:

\begin{aligned} p &= ((39 - 1) * 1 + 3 - 39) / 2 \Rightarrow \\ p &= (38 + 3 - 39) /2 \Rightarrow \\ p &= 1. \end{aligned}

Thus, if the padding is 1, you will have the same output size as the input size, hence it is called same convolution.

To double check

(n + 2p -f) / s + 1 = (39 + 2 * 1 - 3) / 1 + 1 = 39,

which is equal to the input size.

Valid convolution is no padding, hence p = 0.

2 Likes