TensorTau PathToAGI Mathematics of Change Level 02

Level 02 · Mathematics of Change · Chapter 023

Gradient Descent: Teaching a Model to Improve

We know which way is downhill. How far do we step, how many times, and does repeating it actually arrive anywhere?

Where We Are

We now have a compass: the gradient tells us which way the loss rises fastest.

So the machine has a question it can finally answer: which way should I move to make the loss smaller?

Can we turn the gradient into a simple repeatable learning process?

Next → Gradient Descent.

1. The Problem: A Compass Is Not a Journey

Stand at w1=0w_1 = 0, b=0b = 0 on our house-price loss. Chapter 7 computed the gradient there:

∇L=[−38.5−13.0]L(0,0)=45.0\nabla L = \begin{bmatrix} -38.5 \\ -13.0 \end{bmatrix} \qquad L(0,0) = 45.0

Both components are negative, so both dials should increase. Fine — increase them by how much?

Try following the compass literally and stepping the full length of the gradient:

[w1b]←[00]−[−38.5−13.0]=[38.513.0]\begin{bmatrix} w_1 \\ b \end{bmatrix} \leftarrow \begin{bmatrix} 0 \\ 0 \end{bmatrix} - \begin{bmatrix} -38.5 \\ -13.0 \end{bmatrix} = \begin{bmatrix} 38.5 \\ 13.0 \end{bmatrix}

The true answer is w1=2w_1 = 2, b=1b = 1. We wanted to travel a distance of about 2.22.2; we have landed at (38.5,13)(38.5, 13), roughly forty units away, and the loss there is not 45 but 13,54413{,}544. We aimed downhill and ended up three hundred times higher than we started.

Think — The gradient told the truth. It said “from right here, the loss falls fastest in this direction.” It said nothing about how far that remains true, and it could not — it is a statement about an instant, and we took a journey.

So the compass alone is not enough. Three questions block us:

  1. How far should a single step be?
  2. How many steps, and how do we know when to stop?
  3. Does repeating this even work? Nothing so far proves that following a local direction over and over arrives anywhere at all, rather than circling forever or wandering off.

2. What Would a Solution Need?

  1. Use only local information. At a billion parameters we can compute ∇L\nabla L at our current point and essentially nothing else. No map of the whole landscape.
  2. Make progress every step, or at least not go backwards.
  3. Arrive. Repeated application must actually reach the bottom, not merely point at it.
  4. Tell us when it will fail — before we waste a week of compute finding out.
  5. Scale. The same rule must work for 2 parameters and for 101110^{11}.

Requirement 4 is unusual, and by §7 we will be able to predict the exact learning rate at which our own training blows up.


3. First Attempt: Jump Straight to the Bottom

Before iterating, consider the obvious alternative. At the minimum the gradient is zero — Chapter 7 confirmed both partials vanish at (2,1)(2,1). So why not simply solve ∇L=0\nabla L = \mathbf{0} and go there directly?

For our loss we can. Setting both partials to zero:

16.5(w1−2)+5.5(b−1)=05.5(w1−2)+2(b−1)=016.5(w_1-2) + 5.5(b-1) = 0 \qquad 5.5(w_1-2) + 2(b-1) = 0

Two linear equations, two unknowns. Solving gives w1=2w_1 = 2, b=1b = 1 exactly, in one shot, with no iteration and no learning rate. It works perfectly.

And it is a dead end. Here is why.

It needs the loss to be a quadratic. Our loss is a parabola-bowl only because the model is linear and the loss is squared error. Put a single activation function in the model — Chapter 078 does — and ∇L=0\nabla L = 0 becomes a system of equations with no closed-form solution at all. There is nothing to solve.

Even when solvable, it does not scale. Solving nn linear equations costs roughly n3n^3 operations. For n=2n = 2 that is 8. For a small network with n=106n = 10^6 it is 101810^{18} operations — more than a modern GPU can do in a year. For n=1011n = 10^{11} it is beyond absurd.

A Tempting Wrong Idea

“Just set the gradient to zero and solve — iteration is a workaround for people who cannot do algebra.”

It is the reverse. Iteration is what survives when algebra runs out. Direct solution is a luxury available for exactly one family of models, and we will use it — Chapter 038 derives the normal equations and uses them as ground truth to check gradient descent against. But the algorithm that trains every modern network cannot be that one.

We need a method that uses only the local gradient, and gets there by repetition.


4. The Discovery: Small Steps, Repeated

The failure in §1 was not the direction. It was the length. So keep the direction and shrink the step:

  θ  ←  θ−η ∇L(θ)  \boxed{\;\theta \;\leftarrow\; \theta - \eta\,\nabla L(\theta)\;}

The number η\eta — the learning rate — is the fraction of the gradient we actually walk. This is gradient descent, and it is the entire algorithm. Everything after this in the chapter is analysis of when it works.

Watch it run from (0,0)(0,0) with η=0.05\eta = 0.05:

stepw1w_1bbLL
00.00000.00000.00000.000045.000045.0000
11.92501.92500.65000.65000.31330.3133
22.08312.08310.70560.70560.00910.0091
32.09552.09550.71220.71220.00690.0069
52.09522.09520.71690.71690.00670.0067
102.09172.09170.72730.72730.00620.0062
202.08512.08510.74710.74710.00530.0053
2202.01892.01890.94380.94380.0002630.000263

Look carefully, because the shape of this is the whole lesson. Two steps take the loss from 45 to 0.009 — a factor of five thousand. And then it very nearly stops: over the next two hundred steps the loss improves by only another factor of thirty.

Watch the two columns separately and you can see why. w1w_1 arrives almost immediately — it is at 2.082.08 after two steps and barely moves again. Meanwhile bb is at 0.710.71 after three steps and is still only at 0.940.94 two hundred steps later, inching towards its target of 1.

One dial sprints; the other crawls. That is not a flaw in the code, and §6 explains exactly what causes it.

LevelThe same idea
💡 IntuitionWalking down a foggy hillside. You can see only the ground at your feet, so you take a short step downhill, look again, and repeat. You never need a map of the mountain.
✏️ NumbersAt (0,0)(0,0): ∇L=[−38.5,−13.0]\nabla L = [-38.5, -13.0], so with η=0.05\eta=0.05 we move by [+1.925,+0.65][+1.925, +0.65] — a step of the right size, not forty times too big.
🎓 Abstractionθt+1=θt−η∇L(θt)\theta_{t+1} = \theta_t - \eta\nabla L(\theta_t), iterated until the gradient is small.

History Lens — Cauchy, 1847

The method is older than almost everything it now trains. Augustin-Louis Cauchy — the same Cauchy who made Chapter 6’s limits rigorous and who wrote down Chapter 5’s characteristic equation — published it in 1847, in a short note on solving systems of simultaneous equations. His actual problem was astronomical: fitting orbital calculations to observations, where the equations were too tangled to solve directly.

His idea was exactly §4: follow the steepest descent of a quantity you want to minimize, one step at a time.

It then sat mostly unused for a century, because by hand each step is laborious and thousands are needed. The algorithm was waiting for a machine that could repeat arithmetic without getting bored. Gradient descent is a 19th-century idea that had to wait for the 20th century’s hardware — and it now runs on essentially every model in this course.


5. Does It Arrive? The Contraction Argument

Requirement 3 demanded proof, not hope. For our loss we can give one, and it is worth every line because it explains all of the behaviour we see.

Write the error — how far we currently are from the answer — as

et=θt−θ⋆\mathbf{e}_t = \theta_t - \theta^\star

where θ⋆=(2,1)\theta^\star = (2, 1) is the bottom. Chapter 7 showed that for our quadratic loss the gradient is exactly

∇L(θ)=H (θ−θ⋆),H=[16.55.55.52]\nabla L(\theta) = H\,(\theta - \theta^\star), \qquad H = \begin{bmatrix} 16.5 & 5.5 \\ 5.5 & 2 \end{bmatrix}

where HH is the Hessian, the matrix of second derivatives — the multi-dimensional curvature from Chapter 7 §8. Substitute that into the update:

θt+1=θt−ηH(θt−θ⋆)\theta_{t+1} = \theta_t - \eta H(\theta_t - \theta^\star)

Subtract θ⋆\theta^\star from both sides to get the next error:

et+1=et−ηHet=(I−ηH) et\mathbf{e}_{t+1} = \mathbf{e}_t - \eta H\mathbf{e}_t = (I - \eta H)\,\mathbf{e}_t

The error is multiplied by a fixed matrix every step. So after tt steps,

et=(I−ηH)t e0\mathbf{e}_t = (I - \eta H)^{t}\,\mathbf{e}_0

and the entire question “does it arrive?” becomes “does (I−ηH)t(I-\eta H)^t shrink to nothing?” — which is precisely the question Chapter 5 §8 answered about repeated application of a matrix.

Now use the eigenvectors

Chapter 5 taught that a symmetric matrix is just stretching along its eigenvector directions. HH is symmetric, and its eigenvalues are

λmax⁡=18.3501,λmin⁡=0.1499\lambda_{\max} = 18.3501, \qquad \lambda_{\min} = 0.1499

Decompose the error into those two directions. Along an eigendirection with eigenvalue λ\lambda, the matrix (I−ηH)(I - \eta H) simply multiplies by the number (1−ηλ)(1 - \eta\lambda). So that piece of the error behaves as

et=(1−ηλ)t e0e_t = (1 - \eta\lambda)^{t}\,e_0

A number raised to the power tt. That shrinks to zero if and only if its size is below 1:

∣1−ηλ∣<1⟺0<η<2λ|1 - \eta\lambda| < 1 \qquad\Longleftrightarrow\qquad 0 < \eta < \frac{2}{\lambda}

Every eigendirection must shrink, so the binding constraint is the largest eigenvalue:

  η<2λmax⁡  \boxed{\;\eta < \frac{2}{\lambda_{\max}}\;}

For our loss:

η<218.3501=0.108991\eta < \frac{2}{18.3501} = 0.108991

This is Chapter 6’s one-variable rule η<2/L′′\eta < 2/L'', generalized. With one parameter the curvature was one number; with many it is a matrix, and the ceiling is set by its steepest direction — because a single η\eta has to survive the worst case.

The notebook runs it: η=0.108\eta = 0.108 converges, η=0.109\eta = 0.109 does not. The prediction is right to three decimal places, and it was made before running anything.


6. Why It Slows Down

The same argument explains the crawl in §4’s table, and this is the part most people never get told.

Convergence is not governed by one number but by all of them. The fast directions die quickly; the slow ones set how long you wait. At η=0.05\eta = 0.05:

directionλ\lambdacontraction per step ∣1−ηλ∣\lvert 1-\eta\lambda\rvertafter 200 steps
steep18.350118.35010.08250.0825≈10−217\approx 10^{-217} — gone instantly
flat0.14990.14990.99250.99250.220.22 — barely touched

The steep direction is annihilated in a handful of steps. The flat direction shrinks by three-quarters of one percent per step, and that is what you are waiting for.

This is precisely the two-speed behaviour in §4’s table. w1w_1 lies mostly along the steep eigendirection, so it arrives in two steps and stops moving. bb lies mostly along the flat one, so it is still creeping from 0.750.75 towards 11 after two hundred steps. The algorithm is not “converging slowly” — it converged in one direction almost instantly and is waiting on the other.

The ratio of the two eigenvalues has a name we already know — Chapter 5 called it the condition number:

κ=λmax⁡λmin⁡=18.35010.1499=122.4\kappa = \frac{\lambda_{\max}}{\lambda_{\min}} = \frac{18.3501}{0.1499} = 122.4

It measures how badly stretched the bowl is. And it controls the speed directly. Even with the best possible learning rate, the error can shrink no faster than

ρ=κ−1κ+1=121.4123.4=0.9838\rho = \frac{\kappa - 1}{\kappa + 1} = \frac{121.4}{123.4} = 0.9838

per step — about 1.6% per step, needing roughly 42 steps to halve the error and 850 to reach six decimal places. That is the ceiling on performance for this problem, not a property of our code.

Precision, not false simplicity. The learning rate minimizing that worst-case rate is η⋆=2/(λmax⁡+λmin⁡)=0.1081\eta^\star = 2/(\lambda_{\max}+\lambda_{\min}) = 0.1081. But “optimal” here means optimal against the worst starting point. From our particular start at (0,0)(0,0), η=0.10\eta = 0.10 actually finishes closer after 200 steps than η⋆\eta^\star does, because most of our initial error happens to lie along the steep direction, which η=0.10\eta = 0.10 kills faster. Worst-case optimal is not the same as best-on-this-run.

And this is Chapter 2’s lesson returning with a number attached. Chapter 2 found that unscaled features gave a condition number in the millions and made training impossible. Now you can see the mechanism: κ\kappa is exactly the ratio that appears in ρ\rho, and as κ\kappa grows, ρ→1\rho \to 1 and progress stops.

Everything in Chapter 32 — momentum, RMSProp, Adam — exists to beat this ρ\rho. They are not arbitrary tricks; they are attempts to escape a bound that plain gradient descent cannot.


7. 🔬 The Experiment: Four Regimes of the Learning Rate

Predict before reading on. We run from (0,0)(0,0) for 200 steps with η=0.02\eta = 0.02, 0.050.05, 0.100.10, 0.1080.108, 0.1090.109 and 0.120.12. Theory says the ceiling is 0.1089910.108991. Which runs land at (2,1)(2,1), and does failure look like a wrong answer or something else?

Measuring the distance to the true minimum after 200 steps:

η\etadistance to (2,1)(2,1)verdict
0.020.020.1700.170converging, too slowly
0.050.050.06890.0689converging
0.100.100.01510.0151converging well
0.1080.1080.05760.0576converging, just under the ceiling
0.1090.1092.2892.289past the ceiling — moving away
0.120.12overflowdiverged

The theory said 0.1089910.108991. The behaviour changes between 0.1080.108 and 0.1090.109.

Two things are worth noticing. First, failure is not a wrong answer — it is growth. Above the ceiling each step overshoots the valley and lands higher on the opposite wall, and the overshoot compounds geometrically, exactly as (1−ηλ)t(1-\eta\lambda)^t with ∣1−ηλ∣>1|1-\eta\lambda| > 1 predicts.

Second, η=0.02\eta = 0.02 “works” and is still useless — after 200 steps it is ten times further away than η=0.10\eta = 0.10. Slowness is a failure mode too, and it is the more dangerous one, because nothing crashes to tell you.


8. What the Bottom Actually Looks Like

Requirement 3 said “arrive”. Arrive where, exactly?

Gradient descent stops moving when ∇L=0\nabla L = \mathbf{0}. Such a point is called stationary, and Chapter 6 §10 already warned that stationary does not mean minimum. In many dimensions there are three kinds:

A local minimum — curving up in every direction. The algorithm settles here and cannot leave, because every direction is uphill.

A local maximum — curving down in every direction. Gradient descent will never stop here in practice; the tiniest nudge falls away.

A saddle point — up in some directions, down in others. The classic is

f(x,y)=x2−y2f(x,y) = x^2 - y^2

At the origin ∇f=0\nabla f = \mathbf{0}, so the algorithm has no reason to move. But it is a minimum along xx and a maximum along yy — the shape of a horse’s saddle or a mountain pass. The gradient is zero and yet you are not at the bottom of anything.

Local minima, concretely

Our house-price loss is a single clean bowl, which is a special property of linear models with squared error — it is convex, with exactly one minimum. Most losses are not. Take

f(x)=x4−8x2f(x) = x^4 - 8x^2

Its derivative f′(x)=4x3−16x=4x(x2−4)f'(x) = 4x^3 - 16x = 4x(x^2-4) vanishes at x=−2,0,+2x = -2, 0, +2. The second derivative f′′(x)=12x2−16f''(x) = 12x^2 - 16 classifies them: f′′(0)=−16<0f''(0) = -16 < 0 is a maximum, and f′′(±2)=+32>0f''(\pm2) = +32 > 0 are two separate minima, both with f=−16f = -16.

Run gradient descent on it and where you land depends entirely on where you start:

startends at
−3.0-3.0−2-2
−0.5-0.5−2-2
+0.5+0.5+2+2
+3.0+3.0+2+2

The algorithm has no memory and no map. It goes downhill from wherever it happens to be, and different starting points reach different answers. This is why initialization matters (Chapter 33), and why training the same model twice with different random seeds gives different results.

A reassurance worth stating honestly: for very large networks, the practical difficulty is usually not getting stuck in bad local minima. High-dimensional loss surfaces have far more saddle points than local minima, and most minima that are found turn out to be of similar quality. Chapter 51 examines the evidence for this properly rather than asserting it.


9. How It Breaks

FailureWhat it looks likeWhy
η\eta above 2/λmax⁡2/\lambda_{\max}loss grows, then overflow∣1−ηλ∣>1\lvert 1-\eta\lambda\rvert > 1, compounding. §5
η\eta far too smallloss falls, foreverContraction near 1. Nothing crashes; you just wait. §7
Large condition numberfast start, endless crawlρ=(κ−1)/(κ+1)→1\rho = (\kappa-1)/(\kappa+1) \to 1. §6
Saddle pointgradient tiny, loss stuck, not a minimumZero gradient is necessary, not sufficient. §8
Bad initializationdifferent answer every runNon-convex losses have many basins. §8
Stopping on gradient size alonestopping at a saddle or a plateauSmall gradient does not mean good solution.

10. 🎯 Machine Learning Connection

Everything in this chapter is what “training” means. When a log line reads epoch 3, loss 0.42, that is §4 having run a few thousand times.

This chapterIn a real system
θ←θ−η∇L\theta \leftarrow \theta - \eta\nabla Loptimizer.step()
η\etathe single most-tuned hyperparameter in deep learning
η<2/λmax⁡\eta < 2/\lambda_{\max}why your loss suddenly became nan
κ\kappa, the condition numberwhy we normalize inputs (Ch 2) and activations (Ch 33)
ρ=(κ−1)/(κ+1)\rho = (\kappa-1)/(\kappa+1)the bound Adam and momentum exist to beat (Ch 32)
saddle points, local minimawhy seeds change results (Ch 33, Ch 51)
computing ∇L\nabla Lthe hard part — Chapters 27, 28 and 31

One honest gap: we computed ∇L\nabla L from a formula we derived by hand for a two-parameter linear model. No one derives gradients by hand for a network with a hundred layers. How to compute ∇L\nabla L automatically, for any model, cheaply is the subject of Chapters 27–31, and it is the single piece of machinery that made deep learning practical.


11. Distinctions That Matter

Gradient — the direction (Ch 7)Gradient descent — the algorithm that uses it
Direct solution — exact, needs a quadratic, costs n3n^3Iteration — approximate, works on anything, costs nn per step
Diverging — loss grows without boundCrawling — loss falls, uselessly slowly
Stationary point — ∇L=0\nabla L = 0Minimum — stationary and curving up everywhere
λmax⁡\lambda_{\max} — sets the ceiling on η\etaλmin⁡\lambda_{\min} — sets how long you wait
Convex loss — one basin, any start worksNon-convex — many basins, the start decides
η\eta — chosen by youθ\theta — learned from data

12. What We Discovered

  1. A compass is not a journey: stepping the full gradient overshot the answer by a factor of forty.
  2. Solving ∇L=0\nabla L = 0 directly works for our loss and is a dead end — it needs a quadratic, and costs n3n^3.
  3. Keeping the direction and shrinking the step gives gradient descent, the whole algorithm in one line.
  4. For a quadratic the error obeys et+1=(I−ηH)et\mathbf{e}_{t+1} = (I - \eta H)\mathbf{e}_t, so convergence is Chapter 5’s question about repeated application of a matrix.
  5. Along each eigendirection the error is multiplied by (1−ηλ)(1-\eta\lambda) every step, which shrinks exactly when η<2/λ\eta < 2/\lambda.
  6. The ceiling is therefore η<2/λmax⁡=0.108991\eta < 2/\lambda_{\max} = 0.108991, and experiment breaks between 0.1080.108 and 0.1090.109.
  7. The smallest eigenvalue sets the waiting time, so the condition number κ=122\kappa = 122 explains the fast start and long crawl.
  8. Even optimally tuned, the rate is bounded by (κ−1)/(κ+1)=0.9838(\kappa-1)/(\kappa+1) = 0.9838 — the bound Chapter 32’s optimizers exist to beat.
  9. Zero gradient means stationary, not minimal: saddle points and local maxima also qualify.
  10. On non-convex losses the starting point decides the answer, which is why seeds matter.

13. Mathematics We Built

θt+1=θt−η ∇L(θt)\theta_{t+1} = \theta_t - \eta\,\nabla L(\theta_t) ∇L(θ)=H(θ−θ⋆)et+1=(I−ηH) etet=(I−ηH)te0\nabla L(\theta) = H(\theta - \theta^\star) \qquad \mathbf{e}_{t+1} = (I - \eta H)\,\mathbf{e}_t \qquad \mathbf{e}_t = (I-\eta H)^t\mathbf{e}_0 et=(1−ηλ)te0∣1−ηλ∣<1η<2λmax⁡e_t = (1-\eta\lambda)^t e_0 \qquad |1-\eta\lambda| < 1 \qquad \eta < \frac{2}{\lambda_{\max}} κ=λmax⁡λmin⁡η⋆=2λmax⁡+λmin⁡ρ=κ−1κ+1\kappa = \frac{\lambda_{\max}}{\lambda_{\min}} \qquad \eta^\star = \frac{2}{\lambda_{\max}+\lambda_{\min}} \qquad \rho = \frac{\kappa-1}{\kappa+1}

14. What Each Symbol Means

SymbolEnglishIn code
θ\thetaall parameters togetherparams
η\etalearning rate — the fraction of the gradient walkedlearning_rate
θ⋆\theta^\starthe parameters at the bottom—
et\mathbf{e}_terror — how far we still aretheta - theta_star
HHHessian — the curvature matrixhessian
λmax⁡,λmin⁡\lambda_{\max}, \lambda_{\min}steepest and flattest curvaturenp.linalg.eigvalsh(H)
κ\kappacondition numbernp.linalg.cond(H)
ρ\rhobest achievable contraction per step—
IIidentity matrixnp.eye(n)

15. One-Minute Explanation

With no equations:

You are on a foggy hillside and can see only the ground at your feet. Describe how you get to the bottom — and explain the two completely different ways that plan can fail.


16. Exercises

Level 1 — Observe. Look at §4’s table. The loss falls from 45 to 1.2 in one step, then takes 199 more steps to remove the remaining 1.2. Which eigendirection was killed in that first step, and which one are we waiting for? Now look at §7: η=0.02\eta = 0.02 and η=0.109\eta = 0.109 both fail. Describe the difference in how they fail, and say which is more dangerous in practice.

Level 2 — Calculate (by hand, no code). Starting at (w1,b)=(0,0)(w_1, b) = (0,0) with η=0.05\eta = 0.05, use ∂L/∂w1=16.5(w1−2)+5.5(b−1)\partial L/\partial w_1 = 16.5(w_1-2)+5.5(b-1) and ∂L/∂b=5.5(w1−2)+2(b−1)\partial L/\partial b = 5.5(w_1-2)+2(b-1) to compute the first two steps by hand. Then evaluate L=8.25u2+5.5uv+v2L = 8.25u^2 + 5.5uv + v^2 (with u=w1−2u = w_1-2, v=b−1v = b-1) at each point and confirm the loss went 45→0.3133→0.009145 \to 0.3133 \to 0.0091. Finally, explain why w1w_1 has essentially arrived after two steps while bb is still only at 0.710.71.

Level 3 — Derive. Starting from θt+1=θt−ηH(θt−θ⋆)\theta_{t+1} = \theta_t - \eta H(\theta_t - \theta^\star), derive et+1=(I−ηH)et\mathbf{e}_{t+1} = (I-\eta H)\mathbf{e}_t in full. Then, for a single eigendirection, show the error is (1−ηλ)te0(1-\eta\lambda)^t e_0 and deduce the condition 0<η<2/λ0 < \eta < 2/\lambda. Finally prove that the η\eta minimizing max⁡(∣1−ηλmax⁡∣, ∣1−ηλmin⁡∣)\max\big(|1-\eta\lambda_{\max}|,\,|1-\eta\lambda_{\min}|\big) is η⋆=2/(λmax⁡+λmin⁡)\eta^\star = 2/(\lambda_{\max}+\lambda_{\min}). (Hint: at the optimum the two quantities are equal and of opposite sign.)

Level 4 — Investigate (notebook Steps 8–11). Verify the contraction factors: run at η=0.05\eta = 0.05, decompose the error onto the two eigenvectors of HH at each step, and check each component shrinks by exactly ∣1−ηλ∣|1-\eta\lambda| per step. Then find empirically the η\eta that gets closest to the optimum after 200 steps from (0,0)(0,0), and explain why it is not η⋆=0.1081\eta^\star = 0.1081 — what does your starting point have to do with it?

Level 5 — Design. Gradient descent takes one step size in every direction, so §6’s ceiling and crawl are unavoidable. Design a rule that takes large steps along flat directions and small steps along steep ones. What extra information would it need? Estimate its cost per step for nn parameters, and say why that cost rules it out for n=1011n = 10^{11}. Then propose a cheap approximation that keeps most of the benefit — you are inventing the idea behind Chapter 32’s adaptive optimizers.


17. Common Mistakes

MistakeWhy it is wrong
“A bigger learning rate means faster learning.”Only up to 2/λmax⁡2/\lambda_{\max}. Past it you move away from the answer. §5
“The loss went down, so η\eta is fine.”It may be a hundred times too small. Slowness does not announce itself. §7
“It converged, so we are at the global minimum.”Only guaranteed for convex losses. §8
“Zero gradient means minimum.”Saddle points and maxima have zero gradient too. §8
“Iteration is a workaround for not solving it exactly.”Direct solution needs a quadratic and costs n3n^3. §3
“Condition number is a numerical-analysis detail.”It is the difference between 40 steps and 40,000. §6

18. Socratic Questions

  1. The update uses only ∇L\nabla L at the current point. What information about the landscape is it throwing away, and which chapter do you think goes back for it?
  2. We proved convergence for a quadratic loss. Real losses are not quadratic. Does the proof still tell you anything useful near a minimum — and why might “near” be the only place that matters?
  3. If η=2/λmax⁡\eta = 2/\lambda_{\max} exactly, what is ∣1−ηλmax⁡∣|1-\eta\lambda_{\max}|? What does the error do along that direction — shrink, grow, or something else?
  4. §6 says even optimal tuning is bounded by (κ−1)/(κ+1)(\kappa-1)/(\kappa+1). What would κ=1\kappa = 1 mean geometrically, and how many steps would descent need then?
  5. Saddle points have zero gradient but are not minima. If you could only compute gradients and not curvature, how would you ever tell you were sitting on one?
  6. We stop when the gradient is small. Name a situation where that is exactly the wrong stopping rule.

19. 🔭 Bridge to Chapter 026

We now have a complete training algorithm. We know its update rule, we can prove when it converges, we can predict the exact learning rate at which it explodes, and we understand why it crawls. Given a loss function, we can minimize it.

Given a loss function.

Look back at what we have actually been minimizing, all the way from Chapter 1: the mean of the squared differences between prediction and truth. Chapter 1 was honest about where that came from — it said squaring was a choice, made because it removes signs and punishes big mistakes more than small ones, and it explicitly admitted that mean absolute error would have been just as defensible. Then we built eight chapters of machinery on top of that choice and never revisited it.

That should bother you. We have a rigorous method for finding the minimum of a function we picked by taste.

And there is a second thing we have quietly assumed. Our four houses sit exactly on a line — that is why the loss reaches precisely zero. Real house prices do not. Two identical houses on the same street sell for different amounts, because of the weather, the buyer’s mood, a leaking tap noticed on the viewing. Real data scatters, and a model that drives its training loss to zero on scattered data is fitting noise.

So before we can justify a loss, we need a language for describing scatter: what a typical value is, how spread out the values are, and what “noise” even means as a mathematical object.

Real measurements scatter. How do we describe that scatter — and could describing it properly tell us which loss function we should have been using all along?

That is where Chapter 026 begins. Four chapters later, Chapter 033 will derive squared error from first principles — and show that it was never really a choice at all, but a consequence of an assumption about noise we had been making without knowing it.

Six ways to work the chapter, climbing from explaining it in your own words to investigating it like a researcher. Reading is not enough — this is where the chapter lands.

Exercises should progress from understanding to research behaviour.

Level 1 — Explain it

Explain the idea in plain language without equations.

Level 2 — Calculate it

Solve a tiny numerical example by hand.

Level 3 — Predict it

Predict code output, model behaviour, tensor shapes, or graph movement before running anything.

Level 4 — Break it

Deliberately change an assumption or parameter and explain what fails.

Level 5 — Build it

Implement the core mechanism from scratch before using a high-level library.

Level 6 — Investigate it

Form a hypothesis, design an experiment, compare alternatives, and explain the evidence.