Skip to content
nonconvexcard

Approximation Theory and Backpropagation

Universal approximation with its exact hypotheses, why it says nothing about learnability, and backpropagation as reverse-mode differentiation on a computational graph.

Deep LearningAdvanced⏱ 3 hours10 min readuniversal approximationmlpbackpropagationautodiffcomputational graph
5 problems →

From the perceptron to a hidden layer

PropositionA single threshold unit cannot represent XOR

There is no (w,b)∈R2×R(w,b)\in\R^2\times\R with sign⁡(⟨w,x⟩+b)\sign(\ip w{x}+b) equal to x1⊕x2x_1\oplus x_2 on {0,1}2\{0,1\}^2.

This is the observation that halted the first wave of neural network research, and the fix — compose two layers — is what the next theorem generalises.

Universal approximation

TheoremUniversal approximation theorem

Let ρ:R→R\rho:\R\to\R be continuous and not a polynomial. Then for every compact K⊆RdK\subseteq\R^d, every continuous f:K→Rf:K\to\R and every ε>0\eps>0, there exist m∈Nm\in\N, wj∈Rdw_j\in\R^d, bj∈Rb_j\in\R and cj∈Rc_j\in\R with

sup⁡x∈K∣f(x)−∑j=1mcj ρ(⟨wj,x⟩+bj)∣<ε.\sup_{x\in K}\left|f(x) - \sum_{j=1}^m c_j\,\rho\big(\ip{w_j}{x}+b_j\big)\right| < \eps .

Quoted from Leshno et al., which gives the sharp hypothesis; Cybenko and Hornik proved earlier versions for sigmoidal and for bounded non-constant activations. The proof is a functional-analysis argument (the set of such sums is a subalgebra-like family whose closure is shown to be all of C(K)C(K), via Stone–Weierstrass or via a Hahn–Banach separation and a Fourier/Radon-transform computation).

PropositionWhat universal approximation does not give

The theorem is a statement about the closure of a set of functions. It provides:

  • no bound on mm — the width may need to grow exponentially in dd or in 1/ε1/\eps;
  • no algorithm for finding the parameters;
  • no statement about generalisation from finite data;
  • no distinction between activations, architectures or depths.
TheoremDepth separation

There is a function g:Rd→Rg:\R^d\to\R, expressible exactly by a network with three layers and O(poly(d))O(\mathrm{poly}(d)) units, such that any two-layer network approximating gg to constant accuracy in L2L^2 over a natural measure requires eΩ(d)e^{\Omega(d)} units.

Quoted from Eldan and Shamir; Telgarsky gives a complementary one-dimensional construction separating depth kk from depth O(k1/3)O(k^{1/3}) using a sawtooth function whose oscillation count grows exponentially with depth. These are the strongest rigorous statements available about the value of depth, and it is worth being clear about their scope: they show depth can buy exponential efficiency on specially constructed functions. They do not show that the functions arising in practice have this character.

Backpropagation

Represent the network as a computational graph: nodes are intermediate values, edges are elementary operations. For a feedforward net,

a(0)=x,z(ℓ)=W(ℓ)a(ℓ−1)+b(ℓ),a(ℓ)=ρ(z(ℓ)),ℓ=1,…,L,a^{(0)} = x, \qquad z^{(\ell)} = W^{(\ell)}a^{(\ell-1)}+b^{(\ell)}, \qquad a^{(\ell)} = \rho\big(z^{(\ell)}\big), \qquad \ell = 1,\dots,L,

with scalar loss J=ℓ(a(L),y)\mathcal{J} = \ell\big(a^{(L)},y\big).

TheoremBackpropagation computes the exact gradient

Define the adjoints δ(ℓ)=∂J/∂z(ℓ)\delta^{(\ell)} = \partial\mathcal{J}/\partial z^{(\ell)}. Then

δ(L)=∇a(L)ℓ⊙ρ′(z(L)),δ(ℓ)=((W(ℓ+1))⊤δ(ℓ+1))⊙ρ′(z(ℓ)),\delta^{(L)} = \nabla_{a^{(L)}}\ell \odot \rho'\big(z^{(L)}\big), \qquad \delta^{(\ell)} = \Big(\big(W^{(\ell+1)}\big)^\top\delta^{(\ell+1)}\Big)\odot\rho'\big(z^{(\ell)}\big),

and

∂J∂W(ℓ)=δ(ℓ)(a(ℓ−1))⊤,∂J∂b(ℓ)=δ(ℓ).\frac{\partial\mathcal{J}}{\partial W^{(\ell)}} = \delta^{(\ell)}\big(a^{(\ell-1)}\big)^\top, \qquad \frac{\partial\mathcal{J}}{\partial b^{(\ell)}} = \delta^{(\ell)} .

These are exact derivatives (no finite differences), computed in time O(forward pass)O(\text{forward pass}) and memory O(∑ℓdim⁡a(ℓ))O(\sum_\ell\dim a^{(\ell)}).

Key idea

Backpropagation is not an algorithm specific to neural networks and it is not an approximation. It is reverse-mode automatic differentiation applied to a particular graph, and the reason it is cheap is the one on the matrix calculus page: many inputs, one output, so accumulate the Jacobian product from the left. The "many parameters, one loss" shape of deep learning is what makes it affordable, and the memory cost of storing activations is the price.

PropositionGradient magnitude through a deep chain

With J(ℓ)=diag⁡(ρ′(z(ℓ)))(W(ℓ))⊤J^{(\ell)} = \diag(\rho'(z^{(\ell)}))\big(W^{(\ell)}\big)^\top, the input-layer adjoint is

δ(1)=J(1)J(2)⋯J(L−1) δ(L),\delta^{(1)} = J^{(1)}J^{(2)}\cdots J^{(L-1)}\,\delta^{(L)},

so

∥δ(1)∥2≤(∏ℓ=1L−1∥J(ℓ)∥)∥δ(L)∥2,\norm{\delta^{(1)}}_2 \le \left(\prod_{\ell=1}^{L-1}\norm{J^{(\ell)}}\right)\norm{\delta^{(L)}}_2,

and generically ∥δ(1)∥2≈cL\norm{\delta^{(1)}}_2 \approx c^{L} for cc the typical singular value. The gradient is therefore exponential in depth, vanishing for c<1c<1 and exploding for c>1c>1.

Problems

XOR is not linearly separableProof · Foundation · 15 min Derive the backpropagation recursionProof · Intermediate · 30 min Width needed to represent a piecewise linear functionProof · Advanced · 1 hour Gradient magnitude through a deep chainProof · Intermediate · 30 min Implement backpropagation from scratchCoding · Intermediate · 3 hours

References

  • PaperGeorge Cybenko (1989). Approximation by superpositions of a sigmoidal function
  • PaperKurt Hornik (1991). Approximation capabilities of multilayer feedforward networks
  • PaperMoshe Leshno, Vladimir Ya. Lin, Allan Pinkus and Shimon Schocken (1993). Multilayer feedforward networks with a nonpolynomial activation function can approximate any function
  • PaperMatus Telgarsky (2016). Benefits of depth in neural networks
  • PaperRonen Eldan and Ohad Shamir (2016). The Power of Depth for Feedforward Neural Networks
  • PaperDavid E. Rumelhart, Geoffrey E. Hinton and Ronald J. Williams (1986). Learning representations by back-propagating errors
  • BookIan Goodfellow, Yoshua Bengio and Aaron Courville (2016). Deep Learning

These works are cited as sources to read, not reproduced. All exposition, examples and problems on this site are written independently; where an argument is standard, the citation points to a canonical treatment.

Results stated on this page

Problems (5)

All problems

Papers that use this mathematics