Zero padding
Zero padding is the addition of borders filled with zero values around an array or input, often to control convolution output dimensions.
Math and Architectures of Deep Learning
A convolution setting that extends the input with zeros so the kernel can produce outputs near the boundary.
- How it is used
- Controls convolution boundaries and output dimensions when kernels approach the edges of input arrays.
- How deep it goes
- Derives padded input size and boundary positions, but stops short of implementation-specific padding configuration.
- Examples
- Uses a one-dimensional kernel of size three and a final window containing one input value followed by two zeros.
- What you can do after
- Apply it to reason about boundary outputs and calculate how padding changes the effective convolution input.
Read how Math and Architectures of Deep Learning explains zero padding →
Learn Generative AI with PyTorch
The addition of zero-valued borders around an input to control convolution output size.
- How it is used
- Controls convolution output dimensions while extracting spatial features in convolutional neural networks.
- How deep it goes
- Explains borders, output-size effects, tensor dimensions, and scan calculations, but does not derive general convolution formulas.
- Examples
- Uses a 3 × 3 input, a 2 × 2 filter, padding=1, stride=2, explicit scan arithmetic, and a 2 × 2 output tensor.
- What you can do after
- Apply it via nn.Conv2d by setting padding alongside kernel_size and stride to shape convolution outputs.
Read how Learn Generative AI with PyTorch explains zero padding →
Related concepts
- dimensionaddresses · A dimension is an independent coordinate, measurable axis, or descriptive attribute used to represent, locate, or analyze something.
- valid paddingcontrasts with · A convolution padding scheme that adds no extra border values around the input, so the kernel only applies where it fully fits inside the input.
- paddingkind of · Padding is the addition of extra space, values, or data around or within a structure to satisfy size, alignment, layout, or processing requirements.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

