17. Deep Learning

Painting detail by Louis Peyré (1923–2012). About the paintings.
Deep networks learn representations through successive transformations of the input. Their architecture controls which structures they can exploit and how efficiently they can be trained, making it essential to understand the operations within each layer. We develop fully connected and convolutional models and their gradients, then introduce residual connections, normalization, attention, and wavelet scattering.
17.1 Deep Architectures¶
17.1.1 Deep Network Structure¶
Deep learning constructs estimators by composing parameterized maps.
The hidden layers compute a feature representation of the input, and the output layer applies a linear or generalized linear predictor to those features. Unlike a fixed kernel feature map, this representation is learned from the training data.
Feedforward architectures.
A feedforward chain has the structure introduced in (15.20), with the loss omitted. Starting from , compute
so that with
where collects the parameters, and each layer has the dimensions
We focus on feedforward chains. More general architectures use branched computational graphs or share parameters across recurrent steps.
The parameters are fitted by empirical risk minimization (13.11), typically using the stochastic methods of Section 15.2. The resulting objective is generally nonconvex, so Theorem 15.5 does not apply. Under suitable smoothness, noise, and step-size assumptions, one can instead bound measures of stationarity. Initialization and optimization dynamics can also provide implicit regularization.
For chain architectures, reverse mode computes the gradient of the ERM loss (15.13) as described in Section 15.3.5. For convolutional layers, it gives the backpropagation equations (17.3) below. More general computational graphs require the reverse pass to accumulate contributions from every branch and every use of a shared parameter; Section 15.3.4 explains this general procedure.
Deep MLP.
A common computational block consists of
an affine map, with a matrix and a vector parametrized (in most cases linearly) by ,
a nonlinearity independent of , given by
which we write as
In a fully connected layer, every entry of and is trainable, so .
A common choice is a pointwise activation , written as with nonlinear. Such an activation preserves dimension, so . Standard examples are the rectified linear unit (ReLU), , and the sigmoid, .
Interleaving affine maps with nonlinear activations produces increasingly expressive functions .
Training the parameters means minimizing (13.11), for example by stochastic gradient descent. Automatic differentiation computes the gradient at a cost proportional to a forward evaluation, namely for dense layers with pointwise activations. The chain structure gives the backpropagation formula (15.23).
For regression tasks, one usually uses an affine output layer with a squared loss . An output nonlinearity is appropriate when the target is constrained, for example to nonnegative values.
For classification, a multiclass logistic map (13.24) converts the final scores into class probabilities.
For high-dimensional inputs such as images, fully connected layers can require prohibitively many parameters. They also ignore spatial structure and symmetries. Convolutional architectures exploit this structure, as detailed in Section 17.1.3.
Figure 17.1. Panel 1: fully connected network. Panel 2: convolutional neural network.
17.1.2 Perceptron and Shallow Models¶
The logistic classifiers from Sections 13.4.2 and 13.4.3 are simple instances of this network formulation.
The binary logistic model (13.21) is a one-layer () instance of (17.1). Omitting the bias, its components are
The network can include a bias by appending a constant coordinate to . For labels , it is trained with binary cross-entropy:
The resulting empirical-risk objective is convex in the parameters.
For classes, compute the scores and apply the normalized exponential map
For target vectors on the probability simplex, use the cross-entropy loss
17.1.3 Convolutional Neural Networks¶
Signals, images, and videos carry spatial structure that can guide the architecture. Convolutional layers respect translations of the spatial grid, subject to boundary conditions, and reuse the same filters at every location.
At depth , a convolutional network arranges the activation vector as an array in , with spatial positions and channels, so . The spatial positions typically form a one-, two-, or three-dimensional grid.
For an RGB image, is the number of pixels and .
Write , where indexes the spatial position and the channel.
We require the linear map to be translation equivariant. With periodic boundary conditions, this is equivalent to a sum of convolutions across the input channels. The number of output channels may differ from the number of input channels.
The proposition parameterizes an equivariant map by filters indexed by output channel and input channel . Writing for the input channels, the map becomes
and the bias is spatially constant to preserve translation equivariance: for every spatial position , with one trainable scalar per output channel.
This is weight sharing: the same filters act at every spatial position.
A pointwise nonlinearity is followed, when desired, by downsampling to reduce the spatial dimension and computational cost. The filtering/downsampling structure resembles the fast wavelet transform. Let be the downsampling factor, commonly (no reduction) or (a factor of two in each spatial direction). Then
Max-pooling replaces subsampling by local maxima, for example over groups of successive values in one dimension. Strided convolutions provide another way to reduce spatial resolution. These operations preserve equivariance only to shifts compatible with the sampling stride.
Composing local layers enlarges a unit’s receptive field: the set of input locations that can affect it. Its actual sensitivity within that set depends on the parameters, nonlinearities, and input. Multiple channels allow different features to be represented, from local edges to more elaborate patterns.
After spatial downsampling, a classifier can use fully connected output layers or aggregate the spatial features before the final prediction.
The trainable parameters are the filters and biases. To describe backpropagation, consider a single channel per layer, omit biases and downsampling, and use periodic convolution. The forward pass computes
For the loss , let denote the activation gradient. Initialize and, for , compute
Here denotes reversal, and denotes coordinatewise multiplication. The activation and filter gradients are distinct. For a filter with restricted support, retain only the trainable coefficients of the filter gradient. A downsampling layer contributes its adjoint upsampling operator to the reverse pass.
These equations are an instance of reverse-mode automatic differentiation. For nonsmooth activations such as ReLU, implementations choose a derivative convention at the kink; away from such points, the ordinary chain rule applies. More general computational graphs, including shared weights and recurrent connections, require accumulation of all contributions as described in Section 15.3.4.
17.1.4 Advanced Architectures¶
Residual Networks
Residual networks add skip connections at selected layers :
The residual map preserves the dimension. Such connections help stabilize the training of very deep networks and admit an interpretation as explicit Euler steps for an ordinary differential equation.
A common residual block uses a bottleneck:
(ignoring biases), where . Choosing reduces the parameter count and forces the residual map to pass through a lower-dimensional representation.
Batch normalization
Batch normalization [22] standardizes activations during training. For one feature with values in a mini-batch, define
The stabilizer is fixed, while and are learned. During training, the output depends on the whole mini-batch. At inference, stored estimates of the mean and variance are used. For convolutional layers, statistics are usually shared across spatial positions within each channel.
Transformer Networks
A self-attention layer [33] acts on a sequence with . A single scaled dot-product attention head maps
Here and are the learned query, key, and value matrices. For each query index , the weights are nonnegative and sum to one over . Dense attention computes all pairs of scores, so its cost is quadratic in the sequence length for fixed feature dimensions. Transformer blocks combine several attention heads with residual connections, normalization, and positionwise feedforward maps. Positional information is required to distinguish sequence order; without it, unmasked self-attention is permutation equivariant.
17.1.5 Scattering Transform¶
The scattering transform, introduced by Mallat and collaborators, is a convolutional architecture with fixed wavelet filters, modulus nonlinearities, and local averaging. It is a nonlinear extension of the wavelet transform. Its filters are chosen from the geometry of signals and images rather than learned from data. Under appropriate assumptions on the wavelets and deformations, scattering has stability guarantees with respect to small diffeomorphisms. Scattering coefficients can also be used as fixed features before a learned predictor.