A fixed Fourier basis represents a known periodic pattern efficiently. But for a complicated image or a molecular environment, choosing all useful features by hand can be the harder problem. A neural network makes the representation trainable, at the price of coupling feature choice to a nonlinear optimisation problem.
The likelihood interpretation of squared error survives unchanged: replacing by network outputs changes the parameterisation, not the Gaussian observation model. We can therefore focus on what depth adds, how gradients reach early layers, and why a good training fit remains insufficient.
In this chapter: activations, stochastic optimisation, residual learning, regularisation.
Where the nonlinearity enters
An affine layer followed by an elementwise activation computes
Without the activations, composing any number of such layers yields one affine map. Nonlinearity makes new representations possible. For common activations such as tanh and ReLU, sufficiently wide networks with an affine output layer can uniformly approximate continuous functions on compact subsets of Euclidean space. This is an existence statement, under the relevant activation hypotheses; it gives neither a practical width nor a training guarantee. Arbitrary nonlinear activations do not all satisfy the same approximation theorem. Cybenko’s theorem gives a classical continuous-sigmoidal case.
Tanh is smooth and zero-centred, with derivative . For large , it saturates and the derivative becomes small. ReLU, , has derivative one on the positive half-line and zero on the negative half-line; it has no classical derivative at zero. A training implementation chooses a subgradient there. Leaky ReLU keeps a small negative-side slope, allowing updates where ReLU would be inactive.
Compare the functions and derivatives together. A large tanh activation can be almost unresponsive to a further change in its input; an inactive ReLU can be exactly unresponsive.
Backpropagation applies the chain rule through Jacobians , where contains activation derivatives. The early-layer gradient includes products of these matrices. Saturation can contract those products, but the weight matrices also matter. ReLU does not guarantee nonvanishing gradients, nor does tanh make deep learning impossible. Initialisation, normalisation, depth and conditioning determine the combined effect. A unit that remains negative for every training example gets zero ReLU gradient through that branch; a shared change upstream could still make it active later.
A gradient is transported through the same computation in reverse. Follow a unit output derivative back through a small scalar network. Changing the input exposes both tanh saturation and the inactive side of ReLU, while the common weight makes clear that activation derivatives are only part of the product.
δℓ = δℓ₊₁ · w · φ′(w hℓ) · w = 1.1
tanh derivative product = 0.00849ReLU derivative product = 1.611
A useful gradient need not use every observation
For empirical risk , full gradient descent uses . A uniformly sampled mini-batch gives
At a fixed , uniform sampling makes . Biased sampling needs appropriate weights. Random reshuffling across an epoch is useful, but its later batches are not conditionally independent uniform draws given all earlier updates. Each update processes fewer examples; roughly updates constitute an epoch.
The computation saved per update permits frequent progress and mini-batch hardware parallelism. Gradient noise can help leave some unstable or shallow regions, but is not a guarantee of escaping local minima or finding a globally optimal solution. Its covariance depends on the data and current weights. Large learning rates can still destabilise even a convex quadratic: for , , the update is , convergent only for .
A fixed quadratic lets us separate optimisation dynamics from representation learning. Its narrow direction has five times the curvature of its broad one. Play the iterates, then increase the learning rate past the stability threshold: the same downhill direction can produce a divergent sequence when the step is too large.
L(w) = ½(w₁² + 5w₂²) · wnext = w − η∇L(w)
step 0/40loss = 8.400
Adam maintains moving estimates of gradients and squared gradients, with bias corrections, to rescale updates coordinatewise. It changes optimisation dynamics; it does not make the network objective convex. Learning-rate schedules and validation remain consequential for both SGD and adaptive methods.
Finite-step optimisation also selects among available solutions. One local formal calculation illustrates this without claiming a universal generalisation theorem. Under smoothness assumptions, a modified potential
has gradient-flow dynamics that match a deterministic gradient-descent step to the corresponding order in . Indeed, the flow term is cancelled by the gradient of the added term. This is a local small-step approximation, not an exact SGD objective. Mini-batch dynamics require additional stochastic analysis. The source's unconditional “SGD minimises this augmented loss and therefore finds flat, generalising minima” is too strong; notions of sharpness also depend on parameter scaling.
Learn a change to a representation
If a useful representation is already present, a new block should be able to preserve it. A residual block writes
The identity path lets the block express “no change” by learning a small residual. It also introduces short gradient routes through a deep composition. Matching dimensions is necessary; a projection shortcut can replace the identity when widths change. This is the central construction of He et al.'s residual networks.
For a scalar illustration, compare a plain block with derivative to a residual block with residual derivative : repetitions give and . Small residual derivatives can preserve gradients, but kills the residual derivative and positive can cause growth. Skip connections improve trainability without guaranteeing it. Gradient decorrelation or “shattering” is distinct from a small gradient norm; a rapidly varying gradient is not a flat landscape. Expanding products of suggests multiple paths, but a nonlinear ResNet is not literally an average of independent shorter networks.
Batch normalisation is one way to control activation scales. For a feature in a mini-batch, it computes
Learned restore adjustable scale and shift. Training uses batch statistics; inference typically uses stored running statistics, making batch size and distribution shift relevant. Normalisation is useful but is neither required by every residual design nor a proof against exploding gradients.
A depth-scaled update is an Euler step. With appropriate regularity and scaling as , it leads to an ODE. Merely adding infinitely many unscaled blocks does not establish that limit. We use this distinction again in differential-equation models.
Choosing among successful fits
The bias–variance decomposition applies to the entire training algorithm, including architecture, randomness and stopping rule. More parameters can add expressive power, but high parameter count alone neither proves memorisation nor predicts test error. Regularisation changes which fits are preferred.
An explicit penalty gives . The Gaussian-prior interpretation of penalties retains the likelihood scaling derived earlier. Under ordinary SGD, adding gives the update contribution , a multiplicative shrinkage. With adaptive optimisers, decoupled weight decay and an objective penalty generally differ. An penalty encourages sparsity, although plain gradient-based training need not produce the exact zeros of a proximal solver, and sparse internal weights do not automatically identify causal input features.
Early stopping uses validation performance to choose a training duration. Dropout independently masks activations during training; with retention probability , inverted dropout uses , , so the activation's expectation is preserved. Inference usually removes the masks. Shared-weight subnetworks provide an ensemble interpretation, not an exact identity with averaging every nonlinear subnetwork's output.
An explicit ensemble averages independently trained predictions. For predictors with equal error variance and pairwise correlation , the average has variance
Only uncorrelated errors give the full reduction. Shared bias and correlated failures remain. Bayesian neural networks instead integrate predictions over a weight posterior; approximating that posterior is the inference problem developed later. Neither ensembles nor Bayesian terminology alone ensure calibration.
We now have a flexible trainable function, but a dense layer still ignores the organisation of its input. Symmetry and graphs ask which relationships an architecture should preserve before any data are seen.