The core purpose of UAT (Universal Approximation Theorem) is that neural networks can approximate any continuous function, and continuous functions can be approximated by polynomials (Weierstrass theorem).
Weierstrass Theorem
Intuitive Explanation
Suppose
f∈C([0,1])
i.e., f is continuous on [0,1].
Then for any
ε>0
there exists a polynomial P(x) such that
∣f(x)−P(x)∣<ε,∀x∈[0,1].
Next, let's try to prove this theorem.
Step 1: Construct the Bernstein polynomial
Define
Bn(f)(x)=k=0∑nf(nk)(kn)xk(1−x)n−k.
This is the Bernstein polynomial.
Note that
(kn)xk(1−x)n−k
is itself a polynomial in x.
Therefore
Bn(f)(x)
is also a polynomial.
Step 2: Understand what it does. This polynomial is a bit abstract, but we can interpret it in another way.
First note the identity
k=0∑n(kn)xk(1−x)n−k=(x+(1−x))n=1
Thus
Bn(f)(x)
is actually a weighted average of the sequence
f(0),f(n1),…,f(1)
where the weights are
pn,k(x)=(kn)xk(1−x)n−k.
And the sum of these weights is 1.
But we can also interpret it from a probabilistic perspective.
Let the random variable
Xn∼Binomial(n,x).
That is,
P(Xn=k)=(kn)xk(1−x)n−k.
Then
Bn(f)(x)=E[f(nXn)].
This step is very elegant. The Bernstein polynomial is actually the expectation of
f(nXn).
Now let's analyze why it approximates f(x).
For the binomial distribution we have
E(nXn)=x,Var(nXn)=nx(1−x).
Therefore
nXn
becomes more and more concentrated around x.
As n→∞,
nXn→x.
Hence
f(nXn)≈f(x).
Thus
Bn(f)(x)=E[f(nXn)]≈f(x).
Intuitively, this holds.
Rigorous Proof
Since f is continuous on a closed interval, by properties of continuous functions on closed intervals: f must be uniformly continuous. Therefore, for any ε>0 there exists δ>0 such that whenever
∣u−v∣<δ
we have
∣f(u)−f(v)∣<2ε.
Decompose the error:
∣Bn(f)(x)−f(x)∣=E(f(Xn/n)−f(x)).
By the expectation inequality for absolute values:
≤E[∣f(Xn/n)−f(x)∣].
Split into two parts:
A=∣Xn/n−x∣<δ
and
Ac=∣Xn/n−x∣≥δ.
First part: When ∣Xn/n−x∣<δ,
∣f(Xn/n)−f(x)∣<2ε.
The contribution does not exceed 2ε.
Second part: Let M=max[0,1]∣f∣. Then
∣f(Xn/n)−f(x)∣≤2M.
Thus the contribution does not exceed 2M⋅P(∣Xn/n−x∣≥δ).
Using Chebyshev's inequality:
P(∣Xn/n−x∣≥δ)≤nδ2x(1−x)≤4nδ21.
Therefore
2M⋅P(∣Xn/n−x∣≥δ)≤2nδ2M.
When n is sufficiently large,
2nδ2M<2ε.
Thus
∣Bn(f)(x)−f(x)∣<ε.
Moreover, this estimate is independent of x.
Consequently,
x∈[0,1]sup∣Bn(f)(x)−f(x)∣→0.
That is,
Bn(f)→f
uniformly.
Weierstrass theorem is proved.
Proof of the UAT
Next, we will go through the process of proving the Universal Approximation Theorem (UAT) using polynomial approximation, step by step, in language understandable with basic calculus. We take the univariate continuous function as an example for clarity; the vector case can be generalized similarly.
Goal: Given a continuous function f:[a,b]→R and any ϵ>0, there exists a single-hidden-layer neural network
N(x)=i=1∑nαiσ(βix+γi)
such that
∣N(x)−f(x)∣<ϵ,∀x∈[a,b]
where σ is a "non-polynomial, continuous" activation function (e.g., sigmoid).
Step 1: Use the Weierstrass Theorem
We have already proved this theorem earlier: any continuous function can be approximated by a polynomial P(x). That is,
∀ϵ>0,∃P(x) s.t. ∣f(x)−P(x)∣<ϵ/2
Here we do not consider neural networks yet; we transform the problem into "approximating a polynomial". As we know, a polynomial can be written as a0+a1x+⋯+amxm.
Step 2: Approximate monomials xk using an activation function
If we can approximate xk by a linear combination of neurons in one hidden layer, then we can approximate the polynomial P(x).
The single-hidden-layer network has the form:
N(x)=i=1∑nαiσ(βix+γi)
Choose a suitable σ(x), such as the sigmoid:
σ(x)=1+e−x1
Its Taylor expansion is non-zero locally:
σ(x)=21+41x−481x3+…
One can generate arbitrary polynomial terms using linear combinations of its shifted versions.
By adjusting αi,βi,γi, the linear combination
i∑αiσ(βix+γi)
can approximate xk to arbitrary precision (similar to Taylor polynomial approximation in calculus).
Important intuition here: Each neuron is a "nonlinear function block", and summing many such blocks can combine into a polynomial form.
Step 3: Combine to approximate the polynomial
For a polynomial P(x)=∑k=0makxk, for each xk find the corresponding neuron combination Nk(x) that approximates it:
Step 4: Triangle inequality completes the approximation
We have two sources of error:
∣f(x)−P(x)∣<ϵ/2 (Weierstrass theorem)
∣P(x)−N(x)∣<ϵ/2 (neuron approximation of polynomials)
By the triangle inequality:
∣f(x)−N(x)∣≤∣f(x)−P(x)∣+∣P(x)−N(x)∣<ϵ/2+ϵ/2=ϵ
QED.
In other words: the nonlinear units of a neural network act as an "adjustable polynomial basis", and a single layer can combine them into any polynomial, thereby approximating any continuous function.
UAT and the Machine Learning Perspective
This proof is actually quite interesting:
The Bernstein polynomial essentially expresses
f(x)≈k∑f(nk)⋅base function(kn)xk(1−x)n−k
This closely resembles a neural network
f(x)≈i∑ai⋅σ(wix+bi)
The difference is only:
Weierstrass uses polynomial bases xk(1−x)n−k
Neural networks use activation function bases σ(wx+b)
Thus from a modern perspective, the UAT theorem can be understood as a generalization of the Weierstrass theorem to "neural network basis functions". Weierstrass says "the polynomial basis is dense", while UAT says "the neuron basis is also dense".