Lesson 4.1core3 h⚡ live demo

From perceptron to MLP; universal approximation

Stacking dot products and nonlinearities until anything becomes learnable

Every network you will meet — convolutional nets (5.1 Convolution: the operation and its math), the feed-forward block inside a transformer (7.4 Inside the block: residuals, LayerNorm, FFN and embeddings), the value network in an RL agent (4.11 Reinforcement learning essentials) — is a stack of affine maps and simple nonlinearities. Understanding exactly what a multilayer perceptron computes, why a single layer cannot solve XOR, and what the universal approximation theorem does and does not promise gives you the mental model that the rest of deep learning refines rather than replaces.

You'll be able to

  • Write the perceptron, its learning rule and the condition under which it converges
  • Show by explicit construction how one hidden layer solves XOR and why that is representation learning
  • Write the forward pass of an L-layer MLP in both single-example and batched matrix form and count its parameters
  • State the universal approximation theorem precisely and list three things it does not guarantee
  • Explain the geometric picture of a ReLU network as a piecewise-linear function

Key ideas

  1. A perceptron is a thresholded dot product; its learning rule converges only when the data are linearly separable.
  2. XOR is not linearly separable; one hidden layer re-represents the inputs so that a linear rule works — this is representation learning.
  3. An L-layer MLP computes z⁽ˡ⁾ = W⁽ˡ⁾h⁽ˡ⁻¹⁾ + b⁽ˡ⁾, h⁽ˡ⁾ = φ(z⁽ˡ⁾); in batched form each layer is one matrix multiply X Wᵀ + b.
Show 4 more key ideas
  1. Parameter count is Σ (n_{ℓ−1}+1)·n_ℓ; the first layer usually dominates.
  2. Without a nonlinearity, any stack of layers collapses to one affine map.
  3. The universal approximation theorem guarantees existence of a one-hidden-layer approximator, not a reasonable width, learnability by SGD, or generalization.
  4. A ReLU network is a piecewise-linear function; depth multiplies the number of linear regions far faster than width.

Suggested path through this lesson