liveBook · Manning

Zero padding

Zero padding is the addition of borders filled with zero values around an array or input, often to control convolution output dimensions.

How 2 Manning books explain it

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

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.