This Machine Learning concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Machine Learning
MLPs and Universal Approximation
An MLP turns nonlinear hidden units into a weighted feature sum; universal approximation is capacity under assumptions, not a guarantee that training or generalization will succeed.
Concept Structure
MLPs and Universal Approximation
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
4 prerequisites listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Substantive review recorded
1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
You are here because "neural network" should not feel like a magical box. The simplest serious network, the multilayer perceptron, does one powerful thing: it learns hidden features, then adds them together.
Before this, know functions, least-squares fitting, and derivatives. By the end, you should be able to explain why nonlinear hidden units make MLPs more expressive than linear regression, what universal approximation actually promises, and why that promise is not the same as successful training.
A linear model gives every input one flat set of slopes. If the target bends one way on the left and another way on the right, a single line cannot follow both. An MLP first creates hidden features such as "turn on after this threshold" or "saturate around this region." The output layer then forms a weighted sum of those features.
That weighted sum is the useful mental model. A hidden unit is not a neuron mysticism object. It is a learned nonlinear feature. Width gives the model more features to combine. Depth lets features compose into features of features.
Universal approximation says something precise and easy to overstate. In Cybenko's classic form, continuous sigmoidal hidden units can uniformly approximate continuous functions on a compact cube. In the Leshno-Lin-Pinkus-Schocken form, locally bounded piecewise-continuous nonpolynomial activations with thresholds/biases give a broad approximation condition. Neither result says gradient descent will find those weights, that a finite dataset identifies the right function, that the needed width is small, or that the approximation generalizes.
The practical lesson is therefore two-sided:
- MLPs have enough representational capacity to bend beyond linear models.
- Capacity alone is not a learning guarantee. Optimization, data, regularization, initialization, and architecture still decide what happens.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
For a one-hidden-layer scalar-output MLP, let . Define
where , , is applied elementwise, and is the hidden width. The prediction is
where and . In one dimension this can be written as
This is the "weighted sum of hidden features" picture. Each is a feature curve. The output weights decide how strongly that feature contributes.
The nonlinearity is essential. If , then two affine layers collapse:
That is just another affine map. Stacking linear layers without nonlinear activations does not buy curved decision boundaries or curved regression functions.
One common universal-approximation template says: for a compact set , an activation satisfying the theorem's conditions, and any continuous function , for every there exists a width and parameters such that
Read the quantifiers carefully. The theorem says there exist parameters. It does not specify how many units are practical, how to find the parameters from finite noisy data, or whether the learned function behaves well away from the training distribution. Biases or thresholds are part of the usual theorem setup; remove them and the approximation claim can change.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
# Fixed ReLU-hinge features fitted by least squares.
# This is a function-approximation witness, not SGD training.
def f_star(x):
return 0.75 * np.sin(2 * np.pi * x) + 0.25 * np.cos(5 * np.pi * x)
def relu(z):
return np.maximum(z, 0.0)
def design(x, knots):
cols = [np.ones_like(x), x]
cols += [relu(x - k) for k in knots]
return np.column_stack(cols)
x_train = np.linspace(-1, 1, 45)
x_probe = np.linspace(-1, 1, 201)
y_train = f_star(x_train)
y_probe = f_star(x_probe)
for name, knots in {
"linear": [],
"two_hinges": [-0.35, 0.35],
"eight_hinges": np.linspace(-0.85, 0.85, 8),
}.items():
X = design(x_train, knots)
beta = np.linalg.solve(X.T @ X + 1e-4 * np.eye(X.shape[1]), X.T @ y_train)
pred = design(x_probe, knots) @ beta
mse = np.mean((pred - y_probe) ** 2)
print(name, "features:", X.shape[1], "probe_mse:", round(mse, 4))
The code mirrors the math. Each ReLU hinge is a hidden feature. The least-squares solve chooses only the output combination for a fixed feature bank. Real MLP training also learns the hidden weights and uses gradient-based optimization, so this witness is deliberately narrower than full neural-network training.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Choose a model family and predict what will happen before revealing the approximation:
- Still large error: the family cannot bend enough for this target.
- Useful approximation: hidden features combine into a close curve on the domain.
- Memorizes noise: the fitted curve chases sparse noisy samples and looks worse between them.
Before reveal, the demo hides the approximation line, hidden-feature contributions, exact train error, and exact probe error. After reveal, compare the target, weighted sum, error band, and caveat strip. The point is not that eight units is universal. The point is that nonlinear feature sums can create curvature, while universal approximation remains an existence theorem rather than a training or generalization guarantee.
Live Concept Demo
Explore MLPs and Universal Approximation
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what MLPs and Universal Approximation should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
An MLP turns nonlinear hidden units into a weighted feature sum; universal approximation is capacity under assumptions, not a guarantee that training or generalization will succeed.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change MLPs and Universal Approximation should make visible.
Visual Inquiry
Make the image answer a mathematical question
An MLP turns nonlinear hidden units into a weighted feature sum; universal approximation is capacity under assumptions, not a guarantee that training or generalization will succeed.
Which visible object should carry the first intuition?
Pick the cue that should make MLPs and Universal Approximation easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Frames MLPs as feedforward function approximators, compositions of functions, hidden units, and backprop-trained models.
Open sourceSupports affine layers, activation functions, hidden representations, and the nonlinearity needed to avoid collapsing into a linear map.
Open sourceCourse-note bridge for neural network architecture, representational power, and practical caveats around universal approximation.
Open sourceClassic theorem source for dense approximation of continuous functions on compact subsets using sigmoidal hidden units.
Open sourceTheorem-scope source tying universal approximation for standard feedforward networks to nonpolynomial activation behavior.
Open sourceClaim Review
An MLP turns nonlinear hidden units into a weighted feature sum; universal approximation is capacity under assumptions, not a guarantee that training or generalization will succeed.
Claims without a substantive review badge still need exact source-support review.
goodfellow-2016-mlp, d2l-2026-mlp, cs231n-neural-networks-1, cybenko-1989-approximation, leshno-1993-nonpolynomial
Use equations, runnable code, and demos to check whether the source support is operational.
Source support candidates
book 2016Deep Learning, Chapter 6: Deep Feedforward NetworksFrames MLPs as feedforward function approximators, compositions of functions, hidden units, and backprop-trained models.
book 2026Dive into Deep Learning: Multilayer PerceptronsSupports affine layers, activation functions, hidden representations, and the nonlinearity needed to avoid collapsing into a linear map.
course-notes 2026CS231n: Neural Networks Part 1Course-note bridge for neural network architecture, representational power, and practical caveats around universal approximation.
paper 1989Approximation by Superpositions of a Sigmoidal FunctionClassic theorem source for dense approximation of continuous functions on compact subsets using sigmoidal hidden units.
Practice Loop
Try the idea before it explains itself
An MLP turns nonlinear hidden units into a weighted feature sum; universal approximation is capacity under assumptions, not a guarantee that training or generalization will succeed.
Before touching the demo, predict one visible change that should happen in MLPs and Universal Approximation.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to a claim, equation, code, or demo
Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.Open the draft below to save one note and next action in this browser.
MLPs and Universal Approximation
What is the smallest example that makes MLPs and Universal Approximation click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- References to inspect: attached references on this page.
- Definition, prerequisite, and contrast concept links
- The equation or runnable code that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - MLPs and Universal Approximation Selected item key: recorded for copy. Context: Machine Learning Page anchor: recorded for copy. Open question: What is the smallest example that makes MLPs and Universal Approximation click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/machine-learning/mlps-universal-approximation
concept:machine-learning/mlps-universal-approximation