Formula

Formula for Convolution Output Size After Padding

When applying cross-correlation with padding, the spatial dimensions of the output increase. Specifically, if an input tensor of size nextrmhimesnextrmwn_ extrm{h} imes n_ extrm{w} is padded with a total of pextrmhp_ extrm{h} rows (divided roughly equally between top and bottom) and a total of pextrmwp_ extrm{w} columns (divided roughly equally between left and right), and then convolved with a kernel of size kextrmhimeskextrmwk_ extrm{h} imes k_ extrm{w}, the resulting output shape is given by the formula: (nextrmhkextrmh+pextrmh+1)imes(nextrmwkextrmw+pextrmw+1)(n_ extrm{h}-k_ extrm{h}+p_ extrm{h}+1) imes(n_ extrm{w}-k_ extrm{w}+p_ extrm{w}+1).

0

2

Updated 2026-05-12

Tags

Data Science

D2L

Dive into Deep Learning @ D2L