6 Convolutional Neural Networks
Every image classifier we have built so far has ignored the spatial geometry of images, flattening a two-dimensional pixel grid into a one-dimensional vector. The MLP in Chapter 4 treats a \(28 \times 28\) Fashion-MNIST photo as an unordered list of 784 numbers: if we applied the same fixed random permutation to the pixels of every image and retrained, the MLP would reach the exact same accuracy—even though the scrambled images would look like pure static to human eyes. Humans recognize a sneaker by its outline and textures, which are patterns formed by neighboring pixels, and an outline carries the same meaning wherever in the frame it appears.
Neuroscience offered an early clue. In classic experiments on cats and monkeys, Hubel and Wiesel discovered that neurons in the early visual cortex respond to oriented edges and bars within localized patches of the visual field—each neuron’s receptive field (Hubel and Wiesel 1959, 1962, 1968). Later, Field (1987) modeled these responses on natural images using a small bank of local filters swept across every image location (Figure 6.1).
Inspired by these findings, Fukushima’s Neocognitron (Fukushima 1980) organized local detectors into hierarchical layers repeated across space, and LeCun and collaborators showed how to train such architectures end to end via backpropagation to recognize handwritten ZIP codes (LeCun et al. 1989, 1995). Deeper layers of trained vision networks even exhibit representational parallels with higher stages of the primate visual pathway (Kuzovkin et al. 2018), though biology served as architectural inspiration rather than a blueprint for silicon computation.
At the heart of these architectures lies the convolutional layer, which slides a small shared kernel of weights across every neighborhood of an image. Each output unit depends only on nearby pixels, and shifting the input simply shifts the output, building locality and translation equivariance directly into the network while slashing parameter counts by orders of magnitude. These convolutional neural networks (CNNs) drove the watershed breakthrough on ImageNet (Deng et al. 2009; Krizhevsky et al. 2012) and remain a cornerstone of computer vision alongside vision transformers (Chapter 11).
This chapter derives and builds CNNs from first principles in three steps. We begin by showing that enforcing locality and translation equivariance on a dense layer leaves convolution as the unique linear choice (Section 6.1), then implement two-dimensional cross-correlation, learn an edge-detecting kernel by gradient descent, recast convolution as matrix multiplication (im2col), and trace how stacked layers widen receptive fields (Section 6.2). Next, we control spatial resolution, field of view, and feature capacity through padding, stride, and dilation (Section 6.3), multi-channel filter banks and \(1 \times 1\) bottlenecks (Section 6.4), and local and global pooling (Section 6.5). Finally, we assemble these pieces into LeNet (Section 6.6), compare it against our MLP on Fashion-MNIST, inspect its learned first-layer filters, and retrain LeNet on pixel-shuffled images, which by symmetry leave the MLP’s accuracy unchanged, to isolate the contribution of spatial inductive bias. Modern deep convolutional architectures follow in Chapter 7.
Resources and Further Reading
The resources below accompany the sections of this chapter; each names the section it goes with. All are freely accessible online except where noted.
Books
- Deep Learning (Goodfellow, Bengio & Courville): free HTML; Chapter 9 develops sparse interactions, parameter sharing, and equivariance in detail (Section 6.1, Section 6.5).
- Understanding Deep Learning (Simon J. D. Prince): free PDF; Chapter 10 covers convolutions, stride, dilation, and receptive fields with clear geometric figures (Section 6.2, Section 6.3).
- Neural Networks and Deep Learning (Michael Nielsen): free online; Chapter 6 introduces convolutional layers, shared weights, and pooling from first principles (Section 6.2, Section 6.5).
Courses and video lectures
- Stanford CS231n: Deep Learning for Computer Vision: free notes; the “Convolutional Networks” module (layer arithmetic, parameter counting, layer patterns) is a widely used online companion to this chapter (Section 6.3, Section 6.4).
- Michigan EECS 498-007: Deep Learning for Computer Vision (Justin Johnson): free lecture videos working through convolution and pooling arithmetic at this chapter’s pace (Section 6.2, Section 6.5).
Tutorials, notes, and interactive
- A guide to convolution arithmetic for deep learning (Dumoulin & Visin, 2016): free, with companion animations; visual reference for padding, stride, dilation, and transposed convolutions (Section 6.3).
- CNN Explainer (Wang et al., Polo Club): interactive browser convnet for inspecting activations, kernels, and receptive fields (Section 6.4, Section 6.6).
- Computing Receptive Fields of Convolutional Neural Networks (Araujo, Norris & Sim, 2019, Distill): derives the closed-form receptive-field arithmetic introduced in Section 6.2, including strided and multi-path cases.
- Conv Nets: A Modular Perspective (Chris Olah): short classic building intuition for convolution as structured weight sharing (Section 6.1).
- Image Kernels Explained Visually (Victor Powell): interactive tool for sliding hand-designed kernels over an image, complementing Section 6.2.
- Feature Visualization (Olah, Mordvintsev & Schubert, 2017, Distill): visual exploration of what convnet units respond to, accompanying Section 6.6.
Foundational papers
- Gradient-Based Learning Applied to Document Recognition (LeCun, Bottou, Bengio & Haffner, 1998, Proc. IEEE): free PDF; the LeNet-5 paper behind Section 6.6.
- Backpropagation Applied to Handwritten Zip Code Recognition (LeCun et al., 1989, Neural Computation): the first convnet trained end to end with backpropagation (paywalled) (Section 6.6).
- Neocognitron (Fukushima, 1980, Biological Cybernetics): the pre-backpropagation ancestor of alternating convolution and pooling stages (paywalled) (Section 6.5).
- Receptive fields, binocular interaction and functional architecture in the cat’s visual cortex (Hubel & Wiesel, 1962, J. Physiology): free (PMC); the biological root of local receptive fields and hierarchical feature detection (Section 6.1).