3.1.7Neural Network Fundamentals

Universal approximation theorem

2,051 words9 min readdifficulty · medium3 backlinks

WHAT is the theorem?

Read this slowly:

  • What class of functions? Continuous functions on a compact set (bounded + closed).
  • What architecture? Exactly one hidden layer of width NN (a shallow net), linear output.
  • What guarantee? Uniform (sup\sup) closeness — not just on average, but at every point.

WHY is it true? (Derivation from scratch)

We build intuition in 1-D, then note the general case. Goal: show sums of squashed sigmoids can make any bump, and bumps can build any shape.

Step 1 — A single sigmoid is a soft step

The sigmoid is σ(z)=11+ez,σ()=0, σ(+)=1.\sigma(z) = \frac{1}{1+e^{-z}}, \qquad \sigma(-\infty)=0,\ \sigma(+\infty)=1.

Consider σ(w(xb))\sigma\big(w(x-b)\big). Why this step? Multiplying the input by a large ww makes the transition sharp; the bias bb slides the step's location.

  • As ww \to \infty, σ(w(xb))\sigma\big(w(x-b)\big) becomes a hard step that jumps from 0 to 1 at x=bx=b.

Step 2 — Subtract two steps to get a bump

Take two steps at b1<b2b_1 < b_2 and subtract: bump(x)=σ(w(xb1))σ(w(xb2)).\text{bump}(x) = \sigma\big(w(x-b_1)\big) - \sigma\big(w(x-b_2)\big). Why this step? The first step turns "on" at b1b_1; the second turns "on" at b2b_2. Subtracting means we're on (value 1\approx 1) only for b1<x<b2b_1 < x < b_2, and off elsewhere — a rectangular bump of width b2b1b_2-b_1.

This needs 2 hidden neurons with output weights +1+1 and 1-1.

Step 3 — Scale and place many bumps

Divide the domain into many little intervals. On interval kk put a bump of height hkh_k: F(x)=khk[σ(w(xbk))σ(w(xbk+1))].F(x) = \sum_k h_k\Big[\sigma\big(w(x-b_k)\big) - \sigma\big(w(x-b_{k+1})\big)\Big]. Why this step? This is exactly a staircase / histogram approximation of ff. Set hk=f(midpoint of interval k)h_k = f(\text{midpoint of interval }k).

Step 4 — Refine and take the limit

Since ff is continuous on a compact set, it is uniformly continuous: shrink the interval width and every step's height error shrinks below ε\varepsilon. Making ww large sharpens each step. So the staircase converges uniformly to ff. \blacksquare (intuitive version)

Figure — Universal approximation theorem

HOW to use / interpret it


The 80/20 core


Common mistakes


Flashcards

What does the Universal Approximation Theorem guarantee?
A single-hidden-layer network with enough neurons can uniformly approximate any continuous function on a compact set to arbitrary accuracy ε\varepsilon.
The theorem is an ___ result, not an efficiency result.
existence.
Which activations make a shallow net universal (Leshno)?
Any non-polynomial activation (sigmoid, tanh, ReLU...).
How do you build a "bump" from sigmoids?
Subtract two sharp sigmoid steps: σ(w(xb1))σ(w(xb2))\sigma(w(x-b_1))-\sigma(w(x-b_2)).
What does ReLU(x) - ReLU(x-δ) actually produce?
A ramp that rises over [0,δ][0,\delta] and plateaus at height δ\delta — NOT a localized bump; a true bump needs more ReLU units.
Why does compactness matter in the proof?
It gives uniform continuity, so a fine enough staircase of bumps is everywhere within ε\varepsilon.
Neurons needed for M bumps in 1-D (sigmoids)?
N=2MN=2M (two sigmoids per bump).
Why do we still use deep networks if one layer is universal?
Depth achieves the same functions with exponentially fewer neurons and is easier to train; width alone can blow up.
Does the theorem promise good generalization?
No — only fitting on the domain given ideal weights; generalization is separate.
Give an example where the theorem does NOT apply.
1/x1/x on (0,1](0,1] — domain not compact and function unbounded.

Recall Feynman: explain to a 12-year-old

Imagine you want to draw any wiggly line. You have a stamp that makes one small rectangular block. If you stack lots of blocks of different heights side by side, you can trace out any shape, like Lego steps forming a curve. A neuron makes one "on/off" edge; two neurons make one block; many neurons make many blocks. So with enough blocks you can copy any smooth line. The catch: sometimes you'd need a huge pile of blocks — that's why real networks stack layers to be clever instead of just piling millions of blocks.

Connections

  • Sigmoid activation function — supplies the "soft step" bumps.
  • ReLU activation — non-polynomial, hence also universal.
  • Depth vs Width tradeoff — why deep beats wide in efficiency.
  • Uniform continuity — the analysis engine behind the proof.
  • Overfitting and generalization — what the theorem does NOT cover.
  • Backpropagation — how we (try to) find the approximating weights.

Concept Map

large w gives

subtract two

scale and place many

approximates

implements

guarantees

approximates

with tolerance

is only

so needs

motivates

fewer neurons than

Universal Approximation Theorem

Sigmoid activation

Soft step function

Rectangular bump

Sum of scaled bumps

Single hidden layer net

Any continuous function on compact set

Uniform sup closeness

Existence result only

Width N can be exponential

Deep networks

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Universal Approximation Theorem ka core idea bahut simple hai: agar tumhare paas ek hi hidden layer wala neural network hai, lekin usme kaafi saare neurons hain, to woh kisi bhi continuous function ko (jo bounded, closed region par defined ho) itna accurately copy kar sakta hai jitna tum chaho — error ε\varepsilon ko as small as you like rakh sakte ho. Yaani "any shape" banana possible hai.

Kaise? Socho ek sigmoid ek "soft step" banata hai — 0 se 1 tak jump. Do sigmoids ko subtract karo to ek chhota "bump" (rectangle) ban jata hai. Ab aise bahut saare bumps ko alag-alag heights par jodo, to ek staircase ban jati hai jo tumhare target curve ko trace kar leti hai. Function continuous aur domain compact hone ki wajah se uniform continuity milti hai — matlab agar bumps chhote karte jao to error har jagah kam hota jata hai. Yehi proof ka asli engine hai. (Chhoti si baat: ReLU ke saath do units subtract karne se ek ramp milta hai jo δ\delta par plateau kar jata hai, poora rectangular bump nahi — bump ke liye thode aur ReLU units chahiye, lekin universality phir bhi hold karti hai.)

Ek important baat yaad rakhna: yeh theorem sirf existence batata hai, efficiency nahi. Matlab solution exist karta hai, lekin uske liye neurons ki sankhya exponentially badi ho sakti hai, aur gradient descent se woh weights milna guarantee nahi. Isiliye practically hum deep networks use karte hain — kam neurons me kaam ho jata hai aur training easy hoti hai.

Aur ek common galti: "universal" ka matlab yeh nahi ki network unseen data par bhi perfect predict karega. Theorem sirf training domain par fitting ke baare me hai — generalization ek alag topic hai (overfitting, regularization wagairah). Bas yaad rakho: BUMPS BUILD BUILDINGS, aur do keys — Compact domain + Continuous function.

Go deeper — visual, from zero

Test yourself — Neural Network Fundamentals

Connections