6  Convolutional Neural Networks

An image is a two-dimensional grid of pixels, with one or more values at each location. The models introduced so far flatten this grid into a vector before applying a fully connected layer. Flattening discards the explicit spatial relationship between neighboring pixels.

An MLP assigns a separate weight to every input coordinate but has no built-in notion that two coordinates are neighbors. If we permute the pixels in every image consistently and retrain the MLP, we have only renamed its input coordinates; the model class has not changed, even though the spatial layout has disappeared. Ideally, we would use our prior knowledge that nearby pixels are typically related to each other, to build efficient models for learning from image data.

This chapter introduces convolutional neural networks (CNNs) (LeCun et al. 1995). CNNs preserve spatial organization by connecting each output to a local neighborhood and sharing the same weights across locations. On the ImageNet collection (Deng et al. 2009), convolutional neural networks delivered substantial performance improvements (Krizhevsky et al. 2012), and CNN-based architectures dominated computer vision from roughly 2012 to 2021. Today they share the field with vision transformers (Chapter 11) and remain the default where latency, small datasets, or dense prediction dominate.

These restrictions reduce the parameter count relative to a fully connected layer, and convolution kernels can be evaluated in parallel on GPUs (Chetlur et al. 2014). The same operation also appears in models for audio, text, and time series, but this chapter concentrates on images, where locality and translation equivariance have a direct spatial interpretation.

We first derive convolution from locality and translation equivariance in Section 6.1. We then define the operation and show how padding, stride, dilation, channels, and pooling control its shape and information flow. LeNet combines these components in a complete image classifier. The next chapter studies the architectural and training changes that made substantially deeper CNNs practical.

Resources and Further Reading

The references below develop the fundamentals of this chapter: why convolutions, the mechanics of the operation (padding, stride, dilation, channels), receptive fields, pooling, and the first convolutional networks. All are freely accessible online except where noted.

Books

Courses and video lectures

Tutorials, notes, and interactive

Foundational papers