Zero padding adds a visible border of zeros before the same kernel is applied, so edge-centered patches can be computed without hidden values.

highlighted = computed this step

Valid padding stops at the edge

With valid padding, the 3 by 3 kernel only lands where the whole patch is inside the 4 by 4 image. That is why the valid feature map has 2 by 2 cells.

valid cells=(43+1)×(43+1)\text{valid cells}=(4\,-\,3\,+\,1)\times(4\,-\,3\,+\,1)
Convolution setupExact integer image and given integer kernel.input imagec1c2c3c43000300330030003given kernelc1c2c310-110-110-1kernel is given; valid padding and stride one; one exact forward pass; head softmax is NAMED;NOT training; NOT learning

Zero padding adds a visible border

Zero padding with padding 1 surrounds the 4 by 4 image with 0 values, making a 6 by 6 padded grid. The border values are shown, not hidden.

padded image 6×6 with border 0\text{padded image }6\times6\text{ with border }0
Zero paddingVisible zeros make edge patches available.padded image, padding 1c1c2c3c4c5c6000000030000030030030030000030000000zeros are visible border valuespadded row 0, col 0 dot kernelAc1c2c3c4c5c6c7c8c910-110-110-1·xentry000030030products1·0=0Σ=0+0·0=0Σ=0+-1·0=0Σ=0+1·0=0Σ=0+0·3=0Σ=0+-1·0=0Σ=0+1·0=0Σ=0+0·3=0Σ=0+-1·0=0Σ=0result 0corner output cell = 0kernel is given; zero padding is visible and stride one; one exact forward pass; head softmaxis NAMED; NOT training; NOT learning

The corner patch is computable

At padded row 0, col 0, the top-left patch is visible and its dot product with the same kernel is 0.

padded corner output=0\text{padded corner output}=0
Zero paddingVisible zeros make edge patches available.padded image, padding 1c1c2c3c4c5c6000000030000030030030030000030000000zeros are visible border valuespadded row 0, col 0 dot kernelAc1c2c3c4c5c6c7c8c910-110-110-1·xentry000030030products1·0=0Σ=0+0·0=0Σ=0+-1·0=0Σ=0+1·0=0Σ=0+0·3=0Σ=0+-1·0=0Σ=0+1·0=0Σ=0+0·3=0Σ=0+-1·0=0Σ=0result 0corner output cell = 0kernel is given; zero padding is visible and stride one; one exact forward pass; head softmaxis NAMED; NOT training; NOT learning