Marginal

Deep Learning Theory

Why deep learning works, and what we can prove about it: approximation and depth, the generalization puzzle, double descent, the implicit bias of gradient descent, optimization in high dimensions, in-context learning, exact dynamics of deep linear networks, conserved quantities, saddle-to-saddle and lazy regimes, the neural tangent kernel, the edge of stability and SGD noise.

22 lessons in 2 units · free with an account

Start your free trialThis course stays free after the trial.
What you'll learn

22 lessons, one small step at a time

Each lesson states its goal, then works up to it in short steps with practice after each. A placement test at the start skips what you already know.

Mysteries of Deep Learning

12 lessons
  1. Approximation & depthCount the linear pieces a ReLU network can produce, and use the count to show that some functions need exponentially more units without depth.
  2. The generalization puzzleExplain why capacity-based bounds fail for modern networks, what the random-label experiment showed, and which explanations replaced them.
  3. PAC-Bayes boundsCompute a PAC-Bayes bound from the training error and the KL divergence to a prior, and explain how flat minima make such bounds non-vacuous.
  4. Variance of least squaresCompute the variance of least squares from the numbers of features and samples, trace it to small singular values, and draw the classical U-curve.
  5. Double descentDefine least squares with more coefficients than data, compute its variance past the threshold, and explain benign overfitting.
  6. Implicit biasCompute the minimum-norm solution that gradient descent finds in least squares, see how the starting point changes it, and name other algorithms' implicit biases.
  7. Why optimization worksCompute how rare minima are among random critical points in many dimensions, and explain why saddles rather than minima are the typical obstacle.
  8. Induction headsPredict what an induction head outputs, explain the two-head circuit that implements it, and describe how it forms during training.
  9. In-context learningMeasure in-context learning from a model's losses, compute the gradient step that linear attention can implement, and relate trained transformers to the Bayes-optimal predictor.
  10. Hardness of learningExplain why no efficient algorithm learns every function a network can represent, why an idealized Bayesian learner escapes this, and what it implies for explaining training.
  11. Converging representationsSeparate the established observations of similar representations from the Platonic representation hypothesis, and weigh the evidence for it.
  12. Learning as program searchState the program synthesis hypothesis, tell functions from programs, and map the view onto the three mysteries of deep learning.

Training Dynamics

10 lessons
  1. Deep linear networksCompute when a deep linear network learns each singular mode of its target, and explain why learning goes from coarse to fine.
  2. Conserved quantitiesFind a rescaling symmetry of a two-layer network, compute the quantity gradient flow conserves, and explain why the layers stay balanced.
  3. Saddle-to-saddle dynamicsExplain a staircase loss curve as training hopping between saddles, compute how long a plateau lasts and the loss on each, and read a staircase.
  4. Beyond linear networksCompute the loss at each critical point of a deep linear network and the dimension of its minima, and explain how its lessons extend to nonlinear networks.
  5. The neural tangent kernelLinearize a network around its weights, compute its neural tangent kernel, and state when the kernel stays fixed.
  6. Kernel gradient flowCompute how fast training errors decay along each eigendirection of a fixed kernel, and explain the spectral bias this produces.
  7. Lazy vs. rich regimesTell the lazy regime from the rich regime by how the weights move, and explain which settings push training into each.
  8. From lazy to richCompute the threshold at which a mode passes from lazy to rich dynamics, and explain what the transition suggests about grokking.
  9. The edge of stabilityFind the largest stable learning rate on a quadratic, and explain what deep networks do when their sharpness sits at that limit.
  10. SGD noiseCompute how learning rate and batch size set the temperature of SGD noise and its spread near a minimum, and explain its bias toward flat solutions.
Sample lesson

Approximation & depth

Goal: Count the linear pieces a ReLU network can produce, and use the count to show that some functions need exponentially more units without depth.

The universal approximation theorem says a network with one hidden layer can approximate any continuous function. It says nothing about how many units that takes.

We will count linear pieces, compose tents, prove a depth separation, and finish with what it means for real data.

Step 1: Counting linear pieces

A ReLU network computes a piecewise-linear function: on a line of inputs, it is a chain of straight segments joined at kinks. A one-hidden-layer network on a single input is a sum of terms aᵢ·max(0, wᵢx + bᵢ), and each unit contributes exactly one kink, where wᵢx + bᵢ = 0. So with m hidden units the function has at most m kinks, which means at most m + 1 linear pieces.

Turned around: a function with P pieces needs at least P − 1 hidden units in a shallow network. Pieces are a currency for comparing architectures.

Step 2: Composing tents

The tent map t(x) = 2·min(x, 1 − x) rises from 0 to 1 and falls back on [0, 1]: two linear pieces, built from two ReLU units. Composing it with itself, t(t(x)), runs the tent twice across each half, giving four pieces; each further composition doubles the count. After k compositions there are 2k pieces, a sawtooth with 2k − 1 teeth.

A deep network computes this with k layers of 2 units: about 2k units in all. Composition multiplies pieces, while adding units side by side only adds them.

Step 3: Depth separation

Put the two counts together. The k-fold tent has 2k pieces, so a shallow network needs at least 2k − 1 units to reproduce it exactly, while a deep one uses about 2k. Matus Telgarsky (2016) proved more: shallow networks cannot even approximate such sawtooth functions well without exponentially many units. Universal approximation is true, but it can be wildly inefficient.

Depth helps because each layer reuses the previous layer's output: one computation is applied again and again to what came before.

Step 4: What it means for real data

Depth separation shows that some functions are cheap for deep networks and expensive for shallow ones, not that every function is. The argument for depth in practice is that real data often has compositional structure: images are built from edges, then textures, then parts, then objects; sentences from words, phrases and clauses. A function that mirrors such structure is a composition of simpler functions, which is exactly what deep networks compute cheaply.

In the app, each step ends with practice questions, new ones every time, and the lesson comes back later in spaced reviews.

Start Deep Learning Theory

Lessons that need something you haven't learned yet bring it in first, from any course.

Start your free trialThis course stays free after the trial.