Zero padding extends an input array with zeros so a convolution kernel can continue producing outputs near the boundary. With p zeros on each side, an input of size n becomes n + 2p; the kernel then slides across this enlarged array. section 10.2 section 10.8
For valid padding, convolution stops when any kernel element would leave the input. Zero padding instead treats positions outside the array as zero, allowing boundary windows and changing the output size. The same idea extends independently across each dimension of 2D and 3D inputs. section 10.2 section 10.8
A boundary convolution
With a kernel [w0, w1, w2], zero padding lets the final window use [x(n−1), 0, 0]. Its output is y(n−1) = w0 · x(n−1) + w1 · 0 + w2 · 0. The padded values preserve a final output position even though most of the kernel lies beyond the original input. section 10.1.3
| ms + (k − 1) ≤ (n − 1) |
Use the boundary-position inequality to see when a shifted kernel remains within the effective, padded input. section 10.2

