liveBook · Manning

Zero padding

Zero padding extends an array or tensor beyond its boundary with elements equal to zero, often to control the output dimensions of a computation such as convolution.

How 3 Manning books explain it

Grokking GPU Programming

Zero padding extends an input with zero-valued elements beyond its boundary.

How it is used
Defines out-of-bounds values for stencil operations and fills partial CUDA matrix tiles to preserve correctness.
How deep it goes
Explains 1D and 2D boundary behavior and shows zero-filled tile loads, without detailing lower-level hardware behavior.
Examples
Uses a black border around image data, partial matrix tiles, and PyTorch conv2d with padding=1.
What you can do after
Apply zero-valued boundary reads in stencil kernels and use padding=1 for same-sized stride-1 convolution.

Read how Grokking GPU Programming explains zero padding →

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 →

Also covered in

What to know first

Related concepts

Questions about zero padding

What is zero padding?

Zero padding extends an array or tensor beyond its boundary with elements equal to zero, often to control the output dimensions of a computation such as convolution.

Which Manning books explain zero padding?

Grokking GPU Programming, Math and Architectures of Deep Learning and Learn Generative AI with PyTorch.

What should I know before learning zero padding?

Manning books that teach zero padding usually introduce input, array, convolutional layer and dimension first.

What is zero padding a kind of?

Zero padding is a kind of boundary condition. A boundary condition is a value, constraint, or behavior specified at the limit of a mathematical domain or system’s operating range.

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.