Neural Networks: The Multilayer Perceptron and Backpropagation
Anchor (Master): Hastie, Tibshirani & Friedman 2009 The Elements of Statistical Learning 2e (Springer) Ch. 11 (the full statistical treatment, regularization, the bias-variance behaviour); Goodfellow, Bengio & Courville 2016 Deep Learning (MIT Press) Ch. 6 and Ch. 8 (back-propagation and optimization for training); Cybenko 1989 Approximation by superpositions of a sigmoidal function (Math. Control Signals Systems 2) and Hornik 1991 Approximation capabilities of multilayer feedforward networks (Neural Networks 4) for universal approximation
Intuition Beginner
Logistic regression draws a single straight boundary through your data. That is fine when the labels really do separate along a line, but most real patterns bend. A neural network is the simplest honest way to let the boundary bend as much as the data demand: instead of feeding the raw measurements straight into a logistic model, you first pass them through a layer of simple bending units, and only then run the logistic step on what those units report.
Each bending unit does two things. It forms a weighted blend of the measurements — a slope in some direction through the data — and then it squashes that blend through an S-shaped curve, so the unit switches gently from "off" to "on" as you cross its own little boundary. A layer of many such units, each watching a different direction, turns the raw inputs into a richer set of features: "is this point on the high side of unit 3?", "how strongly does unit 7 fire?" The final layer then does ordinary logistic-style classification on those learned features rather than on the raw inputs.
The trick that makes this practical is training: there is a fast, exact way to figure out how to nudge every weight in every layer at once so the network's mistakes shrink. That method is called backpropagation, and it is the engine behind almost everything labelled "deep learning."
Visual Beginner
A network is layers of units, wired left to right. Inputs enter on the left; each later unit blends the values from the layer before it, squashes the blend, and passes it on. The last layer reports the prediction.
| Layer | What each unit does | What comes out |
|---|---|---|
| Input | nothing; just holds a measurement | the raw numbers |
| Hidden | blend the inputs, then squash through an S-curve | "learned features" — bent versions of the data |
| Output | run a logistic / linear step on the hidden features | the prediction (a probability or a number) |
The picture to keep: the hidden layer invents useful features by bending the inputs, and the output layer is just the linear-or-logistic model you already know, sitting on top of those invented features. Forward arrows make a prediction; the dashed backward arrows carry the error back to teach every weight.
Worked example Beginner
Take the smallest pattern that defeats a straight line: the "exclusive-or." Two inputs, each or . The label is when the inputs differ and when they match. So and are label ; and are label . No single straight line can separate these four points — that is the whole point of the example.
Now add two hidden units. Let unit A fire when "at least one input is on," and unit B fire when "both inputs are on." For each of the four cases:
- : A is off, B is off.
- : A is on, B is off.
- : A is on, B is off.
- : A is on, B is on.
The label we want is exactly when "A is on but B is off." That is a simple rule on the two hidden features: fire the output when A minus B is positive. The output unit can do this with a plain weighted sum — A counts , B counts , and we keep the result when it lands above zero.
What this tells us: the raw inputs were not linearly separable, but the hidden features A and B are. The hidden layer rebuilt the problem into one the simple output layer can finish. That is the entire idea of a neural network in miniature — learn features that make the last, easy step possible.
Check your understanding Beginner
Formal definition Intermediate+
Fix an input space and an output dimension . An -layer multilayer perceptron (MLP) is the parameterised map built by composing affine maps with a fixed coordinatewise nonlinearity . Write for the input. For layers ,
where are the weights, the biases, the pre-activations, the activations (the derived features of the hidden layers), and the output transform. The collected parameter vector is . Common hidden nonlinearities are the logistic , the hyperbolic tangent , and the rectified linear unit . The output transform is the identity for real-valued regression and the softmax for -class classification.
The defining structural fact is that the last layer is an ordinary linear (regression) or multinomial-logistic (classification) model fitted not to but to the learned features . Setting , the output is , which is exactly the logistic / softmax form of 45.08.03 with in place of the raw design. An MLP is therefore adaptive basis-function regression: it learns the basis rather than fixing it in advance, and runs a generalized linear model on top.
Training objective. Given i.i.d. data and a per-example loss , the empirical risk is
For regression is squared error ; for classification is the cross-entropy , the negative log-likelihood of the softmax model, generalizing the logistic deviance of 45.08.03. Training minimises (optionally with a penalty) by gradient methods; the gradient is computed by backpropagation.
Counterexamples to common slips
- A network with no nonlinearity is not deep. If is the identity, the composition collapses to a single affine map: no number of linear layers exceeds the expressive power of one. The nonlinearity is what makes depth buy anything.
- Backpropagation is not the optimizer. Backpropagation computes the gradient ; it does not decide the step. The update — gradient descent, stochastic gradient descent
44.06.05, or a quasi-Newton method — is a separate component that consumes the gradient. - Universal approximation is not a learning guarantee. The approximation theorem says a network exists that fits any continuous target; it says nothing about whether gradient descent on finite noisy data will find it, nor how many units the fit needs.
- More parameters than data need not overfit catastrophically. Classical intuition predicts disaster when the parameter count exceeds , but heavily overparameterized networks trained to interpolation often generalize well — the double-descent phenomenon of
45.06.02, which the classical bias-variance curve does not capture.
Key theorem with proof Intermediate+
The signature computational result is that the gradient of the empirical risk with respect to every weight in every layer is obtained by one forward pass and one backward pass through the network, at a cost a fixed multiple of one forward evaluation, independent of the number of parameters. This is backpropagation: the chain rule organised as a reverse-mode sweep over the layered computational graph, the special case of the reverse-mode automatic differentiation of 44.03.08 applied to a scalar loss. The result follows Hastie, Tibshirani & Friedman [Hastie 2009] §11.4 and Goodfellow, Bengio & Courville [Goodfellow 2016] §6.5.
Theorem (the backpropagation recursion). Consider a single example with loss , activations for , output , and . Define the layer error (adjoint) . Then
where is the coordinatewise (Hadamard) product, and the parameter gradients are
Proof. Write as a function of the pre-activations through the composition . The chain rule gives, for the output layer, . When acts coordinatewise, , so . (For the softmax with cross-entropy the same chain rule collapses to the clean form , derived in the Full proof set.)
For a hidden layer , the pre-activation influences only through the next pre-activation . Hence
since . Collecting the index into a vector, the sum is the -th entry of , and the factor multiplies coordinatewise, giving .
Finally, depends on only through that single term, so , i.e. the outer product , and .
Bridge. The proof's engine is that each pre-activation feeds the loss through exactly one downstream layer, so the multivariate chain rule factors into the layerwise recursion : the adjoint flows backward exactly as the activations flowed forward, the transpose playing the role the forward weight played going in. This is exactly the reverse-mode adjoint pass of 44.03.08 specialised to the layered graph, which is the foundational reason the whole gradient costs one forward plus one backward sweep rather than a separate evaluation per parameter — the cheap-gradient principle wearing neural-network clothing. Each per-layer parameter gradient is the rank-one outer product , so the forward activations stored on the way in are precisely the data the backward pass consumes, which generalises the storage-versus-recomputation tradeoff of that unit. The recursion builds toward the optimization layer: backpropagation supplies the gradient that stochastic gradient descent 44.06.05 consumes, and putting these together, the central insight is that an MLP is trained by alternating a forward prediction sweep with a backward error sweep, each adjusting weights in proportion to how much they contributed to the mistake. It appears again at the output layer, where the recursion bottoms out in the softmax-cross-entropy residual , the same error term that drove the logistic fit of 45.08.03.
Exercises Intermediate+
Lean formalization Intermediate+
Mathlib does not host the neural-network layer, so no module is wired in (lean_status: none). The intended statements — the MLP as a parameterised map, the universal-approximation density theorem, and the correctness of the backprop recursion against fderiv — would read roughly as follows.
-- Intended shape; not part of the current Babel Bible Lean build.
-- Requires: a layered map, the activation σ with its derivative, and the
-- adjoint recursion verified against Mathlib's `fderiv`.
variable {p K : ℕ} (σ : ℝ → ℝ)
-- a single affine-plus-activation layer
def layer (W : Matrix (Fin m) (Fin n) ℝ) (b : Fin m → ℝ) (a : Fin n → ℝ) :
Fin m → ℝ := fun i => σ ((W i) ⬝ᵥ a + b i)
-- universal approximation (Cybenko/Hornik): finite single-hidden-layer sums
-- are dense in C(K, ℝ) for a discriminatory σ
theorem universal_approximation
(hσ : Discriminatory σ) (K : Set (Fin p → ℝ)) (hK : IsCompact K) :
DenseRange (fun (net : SingleHiddenLayer σ) => net.toContinuousMap K) := by
sorry
-- backprop correctness: the layerwise adjoint recursion equals the gradient
theorem backprop_eq_fderiv (net : MLP σ) (x y : _) :
backpropGrad net x y = fderiv ℝ (fun θ => loss (net.eval θ x) y) net.θ := by
sorrythe Mathlib gap analysis records what is missing: a formal MLP model, the Discriminatory predicate and the Hahn-Banach / annihilating-measure proof of universal approximation, the empirical-risk objective, and the verified equivalence of the reverse-mode adjoint pass with fderiv.
Advanced results Master
The MLP is a flexible function estimator whose output layer is a generalized linear model on learned features; the results below place its expressive power, its training, and its statistical behaviour on a precise footing.
Theorem 1 (universal approximation). Let be continuous, bounded, and nonconstant, and let be compact. Then for every and every there exist , weights , biases , and coefficients with
Cybenko [Cybenko 1989] proved this for continuous sigmoidal by a Hahn-Banach argument: were the closed span of the functions a proper subspace of , the Riesz representation theorem would supply a nonzero signed measure annihilating , i.e. for all ; a discriminatory (one no nonzero measure can annihilate) forbids this, forcing . Hornik [Hornik 1991] removed the sigmoidal restriction to any bounded nonconstant and extended the density to Sobolev norms (simultaneous approximation of derivatives). The theorem is an existence statement: it bounds neither the width nor the attainability of the approximant by training.
Theorem 2 (backpropagation as reverse-mode AD; the cheap-gradient bound). For an MLP of total computational cost to evaluate, one forward pass storing the activations followed by one backward adjoint pass computes the full gradient — every partial derivative with respect to every weight and bias — in time at most a fixed constant times , independent of the parameter count . This is the cheap-gradient principle of reverse-mode automatic differentiation 44.03.08 specialised to the layered graph: the adjoint is propagated by the transpose recursion of the Key theorem, each elementary operation contributing to the backward sweep a constant multiple of the work it did forward. The memory cost is the storage of the forward activations, per example, recoverable by checkpointing at the price of recomputation — the same time-memory tradeoff that governs reversal of any deep computation.
Theorem 3 (nonconvexity and the role of overparameterization). The empirical risk of a network with at least one hidden layer and a nonlinear is generally non-convex in , with many critical points: permuting hidden units and (for odd ) flipping signs leave unchanged, so every minimum sits in a large orbit of equivalent minima, and saddle points proliferate in high dimension. Gradient descent nonetheless trains such networks reliably in practice, and the modern explanation is overparameterization: when , the loss landscape near initialization is benign — in the wide-network (neural-tangent-kernel) limit the dynamics linearise and gradient descent converges to a global interpolator — and the many parameters provide many descent directions, so first-order methods escape saddles and reach near-zero training loss. Overparameterization trades a worse-conditioned but more navigable landscape for the convexity it forgoes.
Theorem 4 (regularization and the double-descent picture). Three regularizers control the variance of the overparameterized fit. Weight decay adds , the ridge penalty of 45.06.03 applied to the weights, equivalent to a Gaussian prior and shrinking each weight by per step. Early stopping halts gradient descent before convergence; for a linear model with squared loss it is provably a soft spectral shrinkage closely related to ridge, so stopping early caps the effective degrees of freedom. Dropout randomly zeroes a fraction of activations each step, training an implicit ensemble and approximating model averaging. Statistically, the classical bias-variance trade-off 45.06.02 predicts a U-shaped test error in model complexity; deep networks instead exhibit double descent: test error first rises to a peak at the interpolation threshold , then descends again as grows past it, so the most overparameterized models can generalize best — a regime the classical curve does not describe.
Synthesis. The foundational reason an MLP coheres as a statistical object is the layered decomposition into an adaptive feature map followed by a generalized linear output: the hidden layers learn a basis and the last layer runs the logistic / softmax model of 45.08.03 on it, so a neural network is adaptive basis-function regression, and this is exactly the projection-pursuit idea pushed to many composed layers. The training algorithm is dual to this structure: backpropagation propagates the output residual backward through the transposed weights, which is the reverse-mode adjoint pass of 44.03.08 and the central insight that the whole gradient costs one forward plus one backward sweep regardless of how many parameters there are — the cheap-gradient principle is what makes training billion-parameter models feasible at all.
Putting these together, the gradient that backprop computes is consumed by stochastic gradient descent 44.06.05 on a non-convex landscape, and the practical success of this pairing is explained not by convexity but by overparameterization, which is dual to the regularization that controls it: weight decay generalises ridge 45.06.03, early stopping is its spectral shadow, and dropout is implicit averaging. The bridge from classical theory to deep learning is the bias-variance picture of 45.06.02: the U-shaped curve is the foundational reason classical models trade complexity against variance, and double descent is exactly where that picture breaks and is replaced by the interpolation regime, the precise sense in which what classical statistics explains about neural networks — the output GLM, the ridge penalty, the basis expansion — is bounded by what it does not yet explain about why interpolating overparameterized fits generalize.
Full proof set Master
Proposition 1 (a linear network collapses). If is the identity, then for a single matrix and vector, so the composition has no more expressive power than one affine map.
Proof. With , . Unrolling, . Matrix multiplication is associative, so the product is a single matrix, and the accumulated biases form a single vector . Hence , an affine map.
Proposition 2 (the backpropagation recursion). With , the recursion holds for , and , .
Proof. This is the Key theorem. The pre-activation enters only through , so and the chain rule gives , the stated Hadamard-transpose form. Since depends on only through and on linearly, the parameter gradients are the outer product and respectively.
Proposition 3 (softmax-cross-entropy output residual). For the softmax and cross-entropy with one-hot , the output adjoint is .
Proof. The softmax Jacobian is : differentiating with gives, for , , and for , . Then , using . In vector form .
Proposition 4 (cheap-gradient bound for the MLP). One forward pass and one backward pass compute in time at most for an absolute constant , independent of .
Proof. The forward pass evaluates each layer's matrix-vector product and the coordinatewise , costing multiply-adds up to constants. The backward pass, by Proposition 2, computes — a transposed matrix-vector product of the same size as the forward product — and the parameter gradient , another operations. Each layer's backward work is thus a fixed multiple (transpose-multiply plus outer product, roughly to ) of its forward work, and reuses the stored . Summing over layers, total work with an absolute constant; nowhere does the bound reference except through itself, which is the cheap-gradient principle of 44.03.08.
Proposition 5 (universal approximation, density route). For continuous nonconstant bounded and compact , the span of is dense in under the uniform norm.
Proof (Cybenko's Hahn-Banach argument, sketch). Let be the closed linear span of the functions . Suppose . By the Hahn-Banach theorem there is a nonzero continuous linear functional on vanishing on . By the Riesz representation theorem for a nonzero finite signed regular Borel measure , so for every . A sigmoidal (or, after Hornik, any bounded nonconstant) is discriminatory: the only signed measure with for all is . This contradicts , so . (The discriminatory property is established by taking pointwise limits of as to recover indicator-of-halfspace functions, then invoking uniqueness of the Fourier-Stieltjes transform.)
Connections Master
Logistic and softmax regression
45.08.03is the output layer of every classification MLP: the final transform is exactly the multinomial-logistic model of that unit fitted to the learned features rather than to the raw design, and the output adjoint that drives backprop is the softmax generalisation of the logistic residual , so a neural network is the discriminative GLM of that unit sitting on top of an adaptive basis.Automatic differentiation
44.03.08is the backbone of training: backpropagation is precisely reverse-mode AD applied to the scalar empirical risk, and the layerwise adjoint recursion is the adjoint pass over the layered computational graph of that unit. The cheap-gradient bound — full gradient in a constant multiple of one forward evaluation, independent of parameter count — is inherited directly, and the forward-activation storage versus checkpointing tradeoff is the same memory-versus-recomputation balance.Stochastic gradient and mirror descent
44.06.05is the optimizer that consumes the gradients backprop produces: training minimises the non-convex risk by mini-batch SGD, inheriting that unit's noisy-gradient convergence theory, learning-rate schedules, and momentum / adaptive variants, and the implicit regularization of early stopping is an artefact of the SGD trajectory rather than of the objective.Ridge regression and shrinkage
45.06.03is the statistical content of weight decay: the penalty added to the network risk is the / ridge penalty of that unit applied to the weights, equivalent to a Gaussian prior and producing the per-step shrinkage factor , so the bias-variance bargain of regularized regression carries over verbatim to network training.The bias-variance decomposition
45.06.02frames what classical theory does and does not explain about networks: the U-shaped complexity-error curve of that unit is the classical account of overfitting, and the double-descent behaviour of overparameterized networks is exactly where that curve is superseded by the interpolation regime, making this unit the place the bias-variance picture meets its modern boundary.
Historical & philosophical context Master
The perceptron of Rosenblatt (1958) trained a single linear threshold unit; Minsky and Papert's Perceptrons (1969) showed such a unit cannot represent the exclusive-or, a limitation removed only by adding a hidden layer. The algorithm for training the hidden weights — backpropagation — was discovered repeatedly: as reverse-mode accumulation of derivatives over a computational graph it appears in Seppo Linnainmaa's 1970 thesis, and Paul Werbos proposed it for networks in his 1974 dissertation. It entered mainstream use through Rumelhart, Hinton, and Williams' 1986 paper Learning representations by back-propagating errors [Rumelhart 1986], which demonstrated that gradient descent on the squared error, with the gradient computed by the layerwise chain rule, could train multilayer networks to learn internal representations.
The expressive power of a single hidden layer was settled by George Cybenko's 1989 proof [Cybenko 1989] that finite superpositions of a continuous sigmoidal function are dense in the continuous functions on a compact set, established by a Hahn-Banach and Riesz-representation argument rather than by construction. Kurt Hornik's 1991 paper [Hornik 1991], following joint work with Stinchcombe and White, removed the sigmoidal hypothesis to any bounded nonconstant activation and extended density to Sobolev norms, showing the approximation power is a property of the multilayer architecture, not of the particular nonlinearity. The contemporary statistical-learning treatment is consolidated in Hastie, Tibshirani, and Friedman [Hastie 2009] Ch. 11 and in Goodfellow, Bengio, and Courville [Goodfellow 2016], the latter framing backpropagation explicitly as reverse-mode automatic differentiation and documenting the optimization and regularization practice of deep networks.
Bibliography Master
@book{hastie2009elements,
author = {Hastie, Trevor and Tibshirani, Robert and Friedman, Jerome},
title = {The Elements of Statistical Learning: Data Mining, Inference, and Prediction},
edition = {2},
publisher = {Springer},
year = {2009},
note = {Chapter 11, neural networks}
}
@book{goodfellow2016deep,
author = {Goodfellow, Ian and Bengio, Yoshua and Courville, Aaron},
title = {Deep Learning},
publisher = {MIT Press},
year = {2016}
}
@article{cybenko1989approximation,
author = {Cybenko, George},
title = {Approximation by superpositions of a sigmoidal function},
journal = {Mathematics of Control, Signals and Systems},
volume = {2},
number = {4},
pages = {303--314},
year = {1989}
}
@article{hornik1991approximation,
author = {Hornik, Kurt},
title = {Approximation capabilities of multilayer feedforward networks},
journal = {Neural Networks},
volume = {4},
number = {2},
pages = {251--257},
year = {1991}
}
@article{rumelhart1986learning,
author = {Rumelhart, David E. and Hinton, Geoffrey E. and Williams, Ronald J.},
title = {Learning representations by back-propagating errors},
journal = {Nature},
volume = {323},
number = {6088},
pages = {533--536},
year = {1986}
}
@phdthesis{werbos1974beyond,
author = {Werbos, Paul J.},
title = {Beyond Regression: New Tools for Prediction and Analysis in the Behavioral Sciences},
school = {Harvard University},
year = {1974}
}
@book{minsky1969perceptrons,
author = {Minsky, Marvin and Papert, Seymour},
title = {Perceptrons: An Introduction to Computational Geometry},
publisher = {MIT Press},
year = {1969}
}