Universal Approximation & Depth
What one hidden layer can do, and what depth buys.
One hidden layer can approximate any continuous function, but at what price, and with which activations? This lesson proves the exact answer to the second question, shows that for one class of functions networks escape the curse of dimensionality that traps every fixed basis, proves that depth can be exponentially cheaper than width, asks how narrow a deep network may be, and ends with a warning: being able to represent a function does not mean being able to learn it.
What you’ll learn
- Prove that one-hidden-layer networks with a continuous activation are dense in exactly when the activation is not a polynomial.
- State Barron's theorem, derive its rate by sampling hidden units at random, and explain why no fixed basis can match it (the lower bound).
- State Telgarsky's and Eldan & Shamir's depth-separation theorems and explain the piece-counting and Fourier arguments behind them.
- Describe the minimal width at which deep narrow networks become universal, and explain, with hardness results, why approximation says nothing about learnability.
Density: exactly which activations work
Necessity. If is a polynomial of degree , every unit, and so all of , lies in the space of polynomials of degree at most . It is finite-dimensional, hence closed, and it is a proper subspace of whenever has interior. So is not dense.
Reduction to one dimension. Suppose the one-variable span is dense in for every interval . Then every ridge function with continuous is a uniform limit of units on (apply 1-D density on the interval ). Ridge functions suffice, because the powers span all homogeneous polynomials of degree , so polynomials, which are dense by Stone–Weierstrass, are sums of ridge functions:
Smooth in one dimension. The difference quotient is a combination of two units and converges to uniformly for in a compact set. Iterating times and setting puts a monomial in the closure:
If is not a polynomial, no derivative vanishes identically, so for each some has . Then every monomial is in the closure, and by the Weierstrass theorem so is every continuous function on an interval.
General continuous . Smooth it: for a smooth bump with compact support, is a uniform limit on compacts of Riemann sums , which are combinations of units, so the units of lie in the closure of those of . If every such were a polynomial, a Baire-category argument bounds their degrees uniformly and forces itself to be a polynomial. So some is a smooth non-polynomial, and the previous steps apply.
Earlier proofs took other routes. Cybenko (1989) argued by duality: if were not dense, the Hahn–Banach and Riesz representation theorems would give a nonzero signed measure annihilating every unit , and for continuous sigmoidal no such measure exists. Hornik (1991) covered bounded nonconstant activations and approximation as well. The derivative argument above is the most transparent, and it shows why polynomials are the only exception: they are the only functions whose derivatives eventually vanish.
With which activation can one-hidden-layer networks, however wide, fail to approximate uniformly on ?
Show the answer
D.
Every network built from is a polynomial of degree at most 4 in , and those form a closed, finite-dimensional space. Since is not a polynomial, it keeps a fixed positive distance from that space. The other three activations are continuous and not polynomials, so the theorem makes them universal; ReLU even represents exactly with two units.
Rates: Barron's theorem
Density says nothing about width. If all you know about is a smoothness condition (Lipschitz, or bounded derivatives), the number of parameters any reasonable approximation scheme needs for accuracy grows exponentially with , roughly like : the curse of dimensionality (The Curse of Dimensionality). Barron found a class of functions for which networks escape it, and showed that fixed bases cannot.
Since is real, , with the phase of . Multiply and divide by to turn this into an average over the probability distribution :
Each is a ridge function, varying only along , and it is bounded on : the cosine difference is at most .
Draw i.i.d. from and average. In the Hilbert space the error of a sample mean is its variance over , exactly as in Monte Carlo integration:
Some draw does at least as well as the average, so ridge functions achieve error . Barron then replaces each one-dimensional ridge profile by sigmoid units (steps, sharpened), at the cost of the factor 2 in . The argument is Maurey's sampling lemma; the rate comes from choosing the directions to fit , which no fixed basis can do.
In dimensions, suppose a fixed basis has RMS error proportional to (the square root of Barron's barrier), while a network has RMS error proportional to . To halve the error, by what factor must the fixed basis grow?
Show the answer
1024 ×
halves when grows by ; the network needs only times as many units. The catch hides in : the theorem's constant can itself grow with , and many natural functions have (the indicator of a ball, for example, because of its jump).
Two cautions. First, the bound is on approximation; with samples, Barron (1994) balanced it against estimation error and showed that a network with units attains mean squared error of order . Second, the class of functions with , often called the (spectral) Barron class, contains, for example, Gaussians and sufficiently smooth functions, but "sufficiently" means a number of derivatives that grows with , so the curse of dimensionality is moved into the assumption rather than removed.
What depth buys
Pieces multiply with depth. In one dimension, let each unit's input in layer have at most affine pieces. A ReLU at most doubles the pieces of its input, and a sum of such outputs has at most times as many breakpoints. With width at most and layers:
The sawtooth. The tent map maps onto itself twice. Its -fold composition has pieces alternating between 0 and 1, crossing the level exactly times, from only ReLUs.
Few pieces cannot follow many teeth. A function with pieces crosses at most times, so on most of the teeth it stays on one side of while sweeps from 0 to 1 and back; each such tooth contributes a fixed fraction of its width to . If , the error stays above a constant. Taking the target with compositions and comparing with forces width for any network of depth .
Why one hidden layer fails: each unit varies only along , so its Fourier transform is supported on the line , and a width- network has all its spectrum on lines through the origin. The measure has density , where is the indicator of a unit-volume ball, so the error is the distance after convolving both spectra with that ball: each line thickens into a tube around it. The target is a smoothed random signed sum of thin spherical shells, chosen so that its blurred spectrum keeps a constant fraction of its mass far from the origin. That spectrum is radial, so the mass is spread evenly over all directions, while tubes cover only about of each large sphere: the error stays above a constant unless is exponential in . Why two hidden layers succeed: a radial target is a one-variable function of , so the first hidden layer can build the squares , each a one-dimensional approximation, and the second can apply the profile to their sum.
Depth also improves rates for smooth functions: deep ReLU networks approximate to accuracy with layers by a sawtooth construction, and through it products and polynomials (Yarotsky, 2017). For regression with compositional targets, deep ReLU networks attain minimax rates, up to logarithmic factors, governed by the smoothness and dimension of the constituent functions rather than the ambient dimension (Schmidt-Hieber, 2020).
Think first A one-hidden-layer ReLU network on must represent exactly. How many hidden units does it need, and how many does the deep network use?
has pieces, so 1023 kinks. Each hidden unit of a one-hidden-layer network contributes at most one kink, so at least 1023 units are needed (and suffice, by the interpolation construction of the Descent lesson). The deep network uses 10 layers of 2 units: 20 in total. Exact representation is the easy direction; Telgarsky's theorem says even approximation in cannot close the gap.
Narrow networks, and the gap to learnability
Fix the width and let the depth grow. Is a deep, narrow network universal? A first obstruction is elementary: if the first hidden layer has fewer than units, has a nonzero null vector , so for every . The network is constant along a whole line through every point and cannot approximate a bump. The exact thresholds are known:
| Result | Setting | Minimal width |
|---|---|---|
| Lu, Pu, Wang, Hu & Wang (2017) | ReLU, Lebesgue-integrable on , distance | width suffices; at width the error is or , so no that is nonzero on a set of positive measure can be approximated |
| Hanin & Sellke (2017) | ReLU, continuous , uniform distance | exactly for scalar outputs; at most in general |
| Johnson (2019) | uniformly continuous activations that are limits of one-to-one functions (sigmoids, ReLU), uniform distance on compact sets, | width cannot approximate any function with a level set that has a bounded component (a bump, for instance), at any depth |
| Park, Yun, Lee & Shin (2021) | ReLU, | exactly |
Representable is not learnable. Every result above is about existence. Three classical facts show how far existence is from learning:
- Training is NP-hard. Deciding whether a training set in can be fit exactly by a network with two threshold hidden units and one output unit is NP-complete (Blum & Rivest, 1992).
- Gradients can carry no signal. For a family of target functions that are orthonormal under the input distribution, and the squared loss, the variance of the loss gradient across the choice of target is at most , where bounds the second moment of the network's parameter gradient (Shalev-Shwartz, Shamir & Shammah, 2017). For parities on bits it is at most : the gradient is nearly the same whichever parity is the target, so gradient methods need exponentially many steps or exponentially precise gradients, although a small network represents every parity. This is an instance of the statistical-query lower bounds that go back to Kearns (1998).
- Cryptographic hardness. Learning intersections of halfspaces, which are exactly what small networks with one hidden layer of threshold units and an AND output compute, is hard under standard lattice-based cryptographic assumptions, for any efficient algorithm (Klivans & Sherstov, 2009).
So expressivity theorems can only ever be half the story; the other half is which functions gradient descent actually finds from realistic data, the subject of Infinite Width: NTK & Mean-Field Limits and Why Big Networks Generalize.
A ReLU network on has a first hidden layer of 4 units, followed by 100 layers of width 50. Why can it not approximate uniformly on a large cube?
- 100 layers make the gradients vanish
- The first layer's weight matrix has a null vector , so the network is constant along every line in direction , while the target decays along it
- ReLU networks cannot approximate smooth functions
- Width 50 is below the minimal width
Show the answer
B. The first layer's weight matrix has a null vector , so the network is constant along every line in direction , while the target decays along it
Everything after the first layer sees only , which does not change along . On a large cube, points far out along get the same output as points near the origin, so the error is at least about half the target's peak height. The wide later layers cannot recover lost information.
Key takeaways
- A continuous activation is universal for one-hidden-layer networks exactly when it is not a polynomial (Leshno, Lin, Pinkus & Schocken, 1993); differentiating in the weights puts every monomial in the closure.
- Barron: functions with are approximated with integrated squared error by units, a Monte Carlo rate, while fixed basis functions cannot beat .
- Depth separations: ReLU networks with layers of constant width need nodes at depth (Telgarsky); in high dimension, two hidden layers of polynomial width compute a function that a single hidden layer cannot approximate, even to constant accuracy, without exponentially many units (Eldan & Shamir). Pieces grow like .
- Below a width of about , depth cannot help: the minimal width for ReLU universality is for scalar continuous functions on a cube and for .
- Representation is not learning: exact training is NP-hard, gradients carry exponentially little information about parities, and small networks are cryptographically hard to learn.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In the proof that non-polynomial activations are universal, what is the role of differentiating with respect to the weight ?
- It shows the network's loss is differentiable, so gradient descent can find the weights
- It produces as limits of combinations of units, so every monomial, and hence every polynomial, is in the closure
- It proves the activation is bounded
- It computes the Barron norm of the target
Show the answer
B. It produces as limits of combinations of units, so every monomial, and hence every polynomial, is in the closure
Difference quotients of units are combinations of units, and their limits are the derivatives in . At these are ; since a non-polynomial has some with for every , all monomials are reachable, and Weierstrass finishes the proof.
What does Barron's theorem promise for a function with , and what does it deny to linear methods?
- Networks with units reach integrated squared error for every continuous function
- Networks with units reach integrated squared error at most , independent of in the exponent, while fixed basis functions cannot beat order uniformly over the class
- Fixed bases and networks both reach ; networks just have smaller constants
- Networks need units, like every other method
Show the answer
B. Networks with units reach integrated squared error at most , independent of in the exponent, while fixed basis functions cannot beat order uniformly over the class
The rate comes from choosing the inner weights for the target, as in Monte Carlo sampling of a mixture of ridge functions. A fixed basis must cover all directions in advance, and Barron's lower bound shows its worst-case error is at least of order .
A ReLU network on has 3 hidden layers of width 4. By the counting argument, at most how many linear pieces can its output have?
- 13
- 64
- 512
- 4,096
Show the answer
C. 512
Each layer multiplies the piece count by at most , so . A one-hidden-layer network with the same 12 units has at most 13 pieces: depth turns a sum into a product.
A small network represents every parity function on bits. Why does gradient descent still fail to learn a parity of unknown support?
- Parities are not continuous, so no network can represent them
- The loss surface has no minima
- The training set is always too small to contain the information
- The gradient barely depends on which parity is the target: its variance across targets is at most , so it carries almost no information
Show the answer
D. The gradient barely depends on which parity is the target: its variance across targets is at most , so it carries almost no information
Parities are orthonormal under the uniform distribution, so by Shalev-Shwartz, Shamir & Shammah's bound the gradient at any point is nearly identical for all targets. Information exists in the data, but the gradient does not expose it; gradient methods would need exponentially many steps or exponential precision.
Further reading
- A. Pinkus, "Approximation theory of the MLP model in neural networks," Acta Numerica 8, 143–195 (1999).
- A. R. Barron, "Universal approximation bounds for superpositions of a sigmoidal function," IEEE Transactions on Information Theory 39(3), 930–945 (1993).
- M. Telgarsky, "Benefits of depth in neural networks," Conference on Learning Theory (COLT) (2016).
- R. Eldan & O. Shamir, "The power of depth for feedforward neural networks," Conference on Learning Theory (COLT) (2016).
- S. Shalev-Shwartz, O. Shamir & S. Shammah, "Failures of gradient-based deep learning," Proceedings of the 34th International Conference on Machine Learning, PMLR 70, 3067–3075 (2017).