The Modern Mathematics of Deep Learningexplained for non-mathematicians

Beyond the practice set

Our learner can have more adjustable numbers than practice examples. It might even fit a collection of wrong labels perfectly. That sounds like a recipe for memorizing rather than learning.

Yet some large networks still succeed on new examples. The paper examines which parts of the training process and which properties of the learned rule might help explain this.

How does a model identify a penguin?

Training here means measuring each species’ ranges and average. The model then picks the species whose average is closest.

This lab classifies by nearest species average. The Concepts project trains weights with softmax. Same penguin measurements; different classification methods. Predictions can differ.

Real measurements; a nearest-centre classifier you could compute by hand, not a deep network. Data: Kristen Gorman / Palmer LTER; palmerpenguins, CC0

30405060180200220240 40.6 193
Bill length (mm) → · Flipper length (mm) ↑ · ⊕ Selected penguin
  • ● Adelie
  • ▲ Chinstrap
  • ■ Gentoo

Pick a penguin

Bill length (mm)
40.6
Flipper length (mm)
193

Penguin 1 of 3

Not trained yet. Train the model to see how it identifies this penguin.
Training data
Species Penguins Bill range (mm) Average bill Flipper range (mm) Average flipper

Train the model to compute ranges and averages from the 240 training penguins.

2.1 A view through similarity

Kernel regime · paper pp. 23–24

Changing one weight can move predictions for several inputs at once. For example, if the first input number is 1 in one case and 2 in another, raising its weight by 1 raises those predictions by 1 and 2. Features tell us how strongly the predictions move together.

To compare two lists, multiply matching numbers and add: (1, 2) and (2, 1) give 1×2 + 2×1 = 2 + 2 = 4. The paper’s neural tangent kernel compares lists of prediction changes this way. The ribbon activity instead scores how close a length is to 5. Neither score is a probability or a distance.

Compare ribbons

Made-up example

Explore

Compare ribbon lengths: get 10 out of 10. This score compares lengths, not changes in network predictions.

Tap the illustration or use the buttons

Compare ribbons5 cm3 cmSimilarity 6 / 10
Ribbon length (cm)

Current: 3 cm; Target: 5 cm

For the rule Φ(x, θ) = θ₁x₁ + θ₂x₂, θ is the list of weights. The list (x₁, x₂) says how much the prediction changes when each weight rises by one. This list of rates is called the gradient.

Multiply matching entries, then add: 1 × 2 + 2 × 1 = 4.

From the paper

Kθ(x1,x2)=(∇θΦ(x1,θ))T∇θΦ(x2,θ)K_\theta(x_1,x_2)=(\nabla_\theta\Phi(x_1,\theta))^T\nabla_\theta\Phi(x_2,\theta)
Kθ((1,2),(2,1))=1⋅2+2⋅1=4K_\theta((1,2),(2,1))=1\cdot2+2\cdot1=4
function similarity(firstGradient, secondGradient) {
  const similarity = firstGradient[0] * secondGradient[0]
    + firstGradient[1] * secondGradient[1];
  return { similarity };
}
const result = similarity([1, 2], [2, 1]);

Choose a change. Predict, then run.

Result:
Enable JavaScript to run this example.

Go deeper in Concepts paper pp. 23 (2.4)

The neural tangent kernel compares these gradients for two inputs. For very wide networks under certain initialization and training conditions, that comparison changes little as training continues.

In that regime, the lists describing how predictions change with the weights stay nearly fixed. The learner then behaves approximately like a simpler model using those nearly fixed features, even though the network’s output can be nonlinear in its inputs. This is called the kernel regime or lazy training. It describes a particular setting, not every useful network.

2.2 Weight size and room to decide

Norm-based bounds and margin theory · paper pp. 24–25

Counting weights is a crude measure of how freely a network behaves. A large network with small or otherwise controlled weights can differ from one whose weights become enormous.

A score of 6 predicts +1; a score of −6 predicts −1. Multiply the score by the correct label y, which is +1 or −1. The result, M = y×f(x), is called the raw margin. A positive margin means the score chose the correct side; a bigger positive number gives a bigger numerical cushion. Zero is the special boundary.

Cat and dog scores

Made-up example

Explore

Subtract the dog’s 5 points from the cat’s score. Make the gap 3.

Tap the illustration or use the buttons

Cat3 points−+Dog5 pointsScore difference3 − 5 = -2Dog wins
Cat points
3

Score: 3 − 5; Gap: -2

For f(x) = wx with no bias, dividing the raw margin by |w| gives a distance with a sign: positive on the correct side of the boundary. With weight 2 and a positive example at 3, the raw margin is 6. Divide 6 by 2 to get 3 units from the boundary at 0.

The raw score margin is 6. Dividing by weight size 2 gives a signed distance of 3.

Simplified model

M=yf(x),γ=ywx∣w∣(f(x)=wx)M=yf(x),\qquad \gamma=\frac{ywx}{|w|}\quad(f(x)=wx)
M=1⋅2⋅3=6,γ=6/2=3M=1\cdot2\cdot3=6,\qquad \gamma=6/2=3
function classificationMargin(weight, value) {
  if (weight === 0) throw new Error('Weight must be nonzero');
  const score = weight * value;
  const norm = Math.abs(weight);
  return { score, norm, margin: score / norm };
}
const result = classificationMargin(2, 3);

Choose a change. Predict, then run.

Result:
Enable JavaScript to run this example.

Go deeper in Concepts paper pp. 24

A toy cat score of 7 points versus a dog score of 5 leaves a gap of 2 points. If you move the cat score to 3, the gap becomes −2: the dog wins. The illustration shows a score gap; the paper’s signed margin uses the label multiplied by a raw score.

If we double a positive weight, the score and raw margin double, but the boundary stays at 0 and the distance stays 3. The paper studies bounds based on weight sizes and margins under stated assumptions; a large margin alone does not guarantee success on new examples.

2.3 The path matters

Optimization and implicit regularization · paper pp. 25–27

Two networks can make equally few training mistakes, yet predict different answers elsewhere. The process used to find weights can influence which of the many fitting answers we obtain.

Compare two toy rules that both fit the training point (0, 0) but disagree at a new input. This shows a choice among fitting rules. The paper’s result concerns a different task: classification where a straight boundary can separate the two labels.

Two ramps

Made-up example

Explore

Choose the ramp with midpoint 0.5. Both fit the ends.

Tap the illustration or use the buttons

Playground ramp0 m2 mHalfway: 1 mPlayground ramp0 m2 mHalfway: 0.5 m
Ramp

Selected: Straight; Both ramps have the same ends; Middle height: 1

Two toy rules both return 0 at the only training input, 0. At a new input, one returns 0 and the other returns the input.

Training fit alone cannot distinguish these rules; the learning procedure may favor one.

Simplified model

fA(x)=0,fB(x)=xf_A(x)=0,\quad f_B(x)=x
fA(0)=fB(0)=0,fA(1)=0,fB(1)=1f_A(0)=f_B(0)=0,\quad f_A(1)=0,\quad f_B(1)=1
function compareRules(newInput) {
  return { trainingA: 0, trainingB: 0, newA: 0, newB: newInput };
}
const result = compareRules(1);

Choose a change. Predict, then run.

Result:
Enable JavaScript to run this example.

Go deeper in Concepts paper pp. 25

An explicit penalty is a cost we add to the training score. An implicit preference comes from the way the search moves, even when we add no such cost. For example, a search may favor one of several rules that fit. Under special conditions, gradient descent on simple linear models tends toward small weights or a large margin.

The paper also discusses the shape of nearby loss values, or flatness. These ideas offer possible explanations for generalization but do not establish that any particular deep network will find the best generalizing solution.

2.4 A second descent

Limits of classical theory and double descent · paper pp. 27–29

With too few adjustable numbers a model may miss a real pattern. Giving it more freedom often helps at first. Classical teaching suggests that still more freedom eventually causes trouble by fitting noise.

But some models show a different curve. Error on new examples can rise near the point where the model first fits all practice labels, then fall again as the model grows larger. The paper calls this double descent.

Count the mistakes

Made-up example

Explore

Find the lowest tested error after the peak on this invented curve.

Tap the illustration or use the buttons

Mistakes on new cards1 settings · 4 wrongTen picture cardsMade-up comparison
Model size
1

Current: 1; Error: 4

For the two values −1 and +1, the average is 0. Their squared distances from 0 are 1 and 1, with average 1. That average is called variance. The paper studies independently drawn random features with variance 1. Their true weights are zero, so they carry no target signal. Random noise also has variance 1. The result compares numbers of weights and examples as both become large.

The values rise toward the threshold and fall again on the other side.

Simplified model

V(κ)={κ/(1−κ)0<κ<11/(κ−1)κ>1V(\kappa)=\begin{cases}\kappa/(1-\kappa)&0<\kappa<1\\1/(\kappa-1)&\kappa>1\end{cases}
V(1/2)=1,V(3/4)=3,V(3/2)=2,V(3)=1/2V(1/2)=1,\quad V(3/4)=3,\quad V(3/2)=2,\quad V(3)=1/2
function varianceByRatio(ratios) {
  const variance = [];
  for (const ratio of ratios) {
    if (!(ratio > 0) || ratio === 1) {
      throw new Error('Ratio must be positive and different from 1');
    }
    if (ratio < 1) variance.push(ratio / (1 - ratio));
    else variance.push(1 / (ratio - 1));
  }
  return { ratios, variance };
}
const result = varianceByRatio([0.5, 0.75, 1.5, 3]);

Choose a change. Predict, then run.

Result:
Enable JavaScript to run this example.

Go deeper in Concepts paper pp. 28

The illustration has invented mistake counts for different sizes; move the control and read the plotted value. It is not experimental evidence or a prediction for your own network.

The paper analyzes particular linear-regression settings where such behavior can be derived mathematically. Whether more parameters help depends on the input distribution, correlations and the learning algorithm. Bigger does not always mean better.

We saw similarity-based training, margins, the preference of training algorithms and double descent. They describe different conditions under which size alone fails to tell the whole story. Next we ask what the number of layers changes.

Try the chapter quiz

1. Compare the prediction-change lists (1, 2) and (2, 1). What is 1×2 + 2×1?

2. A cat picture gets a cat score of 7 and a dog score of 5. What is the gap between the scores?

3. What does double descent describe?

An independent educational explanation of The Modern Mathematics of Deep Learning — Julius Berner, Philipp Grohs, Gitta Kutyniok, Philipp Petersen. Examples use invented numbers unless a measured dataset is credited.