liveBook · Manning

Chapter 10: Convolutions in neural networks

What you will learn in chapter 10 of Math and Architectures of Deep Learning

This introduction explains why convolutional layers analyze local image patterns with shared weights and how stacked, trainable convolutions form hierarchical visual features within neural networks.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains why convolutional layers analyze local image patterns with shared weights and how stacked, trainable convolutions form hierarchical visual features within neural networks.

Key terms: convolution, convolution layer, local connections, local patterns, spatially adjacent input values, shared weights, convolution operator, fully connected layer, global view, multilayer convolutional neural networks

10.1 One-dimensional convolution: Graphical and algebraical view

This section introduces 1D convolution as a sliding weighted-sum operation and defines the input, kernel, stride, padding, and output positions that determine it.

Key terms: 1D convolution, input array, kernel, kernel weights, slide stop, output array, input, output, n, o

10.1.1 Curve smoothing via 1D convolution

This section shows that a normalized equal-weight 1D convolution kernel performs local averaging to smooth a signal and reveal its broad trend while suppressing short-term noise.

Key terms: 1D kernel, equal weights, normalized, local averaging, smoothing, moving average, broad trend, short-term fluctuations, noise, low-pass filter

10.1.2 Curve edge detection via 1D convolution

This section defines edges as sharp changes in a one-dimensional signal, describes an edge-detection convolution’s responses, and explains why edges are informative.

Key terms: edge, input array, convolution kernel, edge-detection convolution, filter, high response, output value, semantic clues, flat uniform regions, human visual cortex

10.1.3 One-dimensional convolution as matrix multiplication

This section recasts one-dimensional convolution as multiplication by a sparse, structured weight matrix, showing why it can be trained like a linear layer.

Key terms: convolution, kernel, stride, valid padding, linear combinations, moving weighted local sum, matrix-vector multiplication, weight matrix, sparse, block-diagonal structure

10.1.4 PyTorch- One-dimensional convolution with custom weights

This subsection shows how PyTorch performs one-dimensional convolution with manually chosen kernels and contrasts that demonstration with the usual learned convolution-layer weights.

Key terms: torch.nn.Conv1d, torch.nn.functional.conv1d, input tensor, weight tensor, 1D convolution, kernel, weights, convolution layer, stride, padding

10.2 Convolution output size

This section derives convolution output size from kernel size, input size, stride, and optional zero-padding.

Key terms: kernel, input size, stride, valid padding, output size, left end, right end, shift, last valid position, zero-padding

10.3 Two-dimensional convolution: Graphical and algebraic view

This section introduces 2D convolution as a spatially local sliding weighted-sum operation on images, defining its kernel, stride, padding, output grid, and algebraic form.

Key terms: rasterize, two-dimensional neighborhoods, local patterns, pixel, Manhattan distance, 2D convolution, kernel, input array, output array, slide stop

10.3.1 Image smoothing via 2D convolution

This subsection shows how a uniform 2D convolution kernel smooths a noisy image by replacing each pixel with a local weighted average of its neighboring pixels.

Key terms: 2D convolution, image smoothing, denoising, salt-and-pepper noise, uniform kernel, uniform weights, kernel, output pixel, weighted local average, 3 × 3 input pixels

10.3.2 Image edge detection via 2D convolution

This section explains why image edges are semantically useful and how specially chosen 2D convolution kernels detect them by suppressing uniform regions and responding strongly to sharp color changes.

Key terms: semantic importance, edge pixels, silhouette, image understanding, sharp changes in color, 2D convolution, kernel, weighted sum, uniform regions, sharp jump in color

10.3.3 PyTorch- 2D convolution with custom weights

This subsection shows how to supply custom 2D convolution kernels in PyTorch and prepare a 2D image for the Conv2D input interface.

Key terms: kernel, uniform weights, antisymmetric weights, local smoothing, edge detection, Conv2D, N × C × H × W, batch size, channels, height

10.3.4 Two-dimensional convolution as matrix multiplication

This section recasts a specific valid 2D convolution as multiplication of a rasterized image vector by a structured weight matrix.

Key terms: rasterized 1D vector, convolution weight matrix, slide stop, kernel weights, receptive field, valid padding, stride, 2 × 2 kernel, 9 × 16 weight matrix, 3 × 3 convolution output image

10.4 Three-dimensional convolution

This section represents video as a spatio-temporal volume and explains why and how a 3D convolutional kernel extracts patterns, including motion, across space and time.

Key terms: spatio-temporal volume, ST volume, frame, pixel, 2D convolution, 3D convolution, motion, successive frames, kernel, stride vector

10.4.1 Video motion detection via 3D convolution

This subsection explains how a 3D convolution kernel detects video motion by comparing spatially averaged pixel values across successive frames.

Key terms: 3D convolution, 2 × 3 × 3 kernel, space-time volume, ST volume, spatial neighborhood, motion detector, regions of motion, regions of no motion, boundary of motion

10.4.2 PyTorch- Three-dimensional convolution with custom weights

This section explains the PyTorch tensor and kernel shapes needed to implement a 3D convolution for motion detection with custom weights.

Key terms: N × C × D × H × W, batch size, input channels, sequence length, grayscale images, Cout × Cin × kT × kH × kW, output channels, 3D filters, kernel bank, kT

10.5 Transposed convolution or fractionally strided convolution

This section introduces transposed convolution as multiplication by a convolution weight matrix’s transpose, which upsamples an output without reconstructing the original input.

Key terms: transposed convolution, fractionally strided convolution, transposed weight matrix, upsampling, forward convolution, downsampling, valid padding, non-invertible, information loss, backpropagation

10.5.1 Application of transposed convolution: Autoencoders and embeddings

This section explains how an autoencoder uses a convolutional encoder and a transposed-convolution decoder to learn compact embeddings by reconstructing its inputs.

Key terms: embedding, descriptor vector, encoder, convolution layers, autoencoder, decoder, transposed convolution, reconstructed input, reconstruction loss, end-to-end learning

10.5.2 Transposed convolution output size

This subsection explains that a transposed convolution’s output size is found by inverting the ordinary convolution output-size equation and illustrates it with a numerical example.

Key terms: transposed convolution, output size, stride, valid padding, kernel

10.5.3 Upsampling via transpose convolution

This section explains how transpose convolution upsamples low-resolution feature maps, especially in decoders, using learned mappings rather than fixed interpolation.

Key terms: transpose convolution, upsampling, nearest neighbor interpolation, bilinear interpolation, bicubic interpolation, learned mapping, autoencoder, encoder, decoder, embedding

10.6 Adding convolution layers to a neural network

This section explains that practical convolutional networks learn convolution weights through backpropagation rather than using manually chosen filters, and introduces the setup required to add such layers.

Key terms: custom weights, convolution weights, loss minimization, backpropagation, dimensions, weight initialization, convolution layer, neural network, loss.backward(), weight values

10.6.1 PyTorch- Adding convolution layers to a neural network

This subsection shows the PyTorch structural pattern for placing multiple 2D convolutional layers inside a neural-network class.

Key terms: torch.nn.Module, __init__(), forward(), torch.nn.Sequential, torch.nn.Conv2d(), convolutional layer

10.7 Pooling

This section explains how pooling downsamples convolutional feature maps to make CNNs more robust to small feature-location changes.

Key terms: pooling layers, downsampling, feature map, local translation invariance, pooling layer, pooling operation, local patch, max pooling, average pooling, kernel size

10.8 Summary

This summary recaps how convolutions, transposed convolutions, and pooling process local patterns and change the spatial size of 1D, 2D, and 3D data.

Where this is used later

Concepts explained in this chapter

← Chapter 9: Loss, optimization, and regularization Chapter 11: Neural networks for image classification and object detection →

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.