Since Part II you've dragged the learning-rate slider by hand, watching for the value that converges fastest without blowing up. What if, instead of dragging it yourself, you just tried every candidate and let the numbers pick the winner?
Same starting point, same loss, same fixed budget of 20 steps — only the learning rate changes. Step through the candidates and watch identical mechanics produce a slow crawl, a perfect landing, an endless bounce, or a runaway explosion.
A hyperparameter is a setting chosen before training — not learned from data, but fixed in advance and left for you to pick. Grid search turns picking into search: define a set of candidate values, run the full training procedure once per candidate, and keep whichever one scores best on held-out data (the same evaluation machinery built in the last two chapters).
- — the hyperparameter being tuned; here, the learning rate.
- — the finite set of candidate values grid search tries.
- — the model trained end-to-end using that candidate value.
- — the held-out loss used to score each trained candidate.
- best — the candidate value that scored the lowest loss.
- Exhaustive, not clever
It's exhaustive and it's dumb — nothing here is smarter than you dragging the slider by hand.
- But reliable in ways manual search isn't
It never gets tired, never misses a candidate you forgot to try, and never fools itself into stopping at a "good enough" value it found first.
Six learning rates, one 20-step training run apiece. Most land somewhere between "still far off" and "essentially perfect." One lands on the minimum exactly. One never improves at all. One detonates. Grid search doesn't need to understand why — it just measures every outcome and reports the winner.
Minimizing from , 20 steps, six candidate learning rates :
- Too small crawls, symmetric rates tie
- : loss after 20 steps — still visibly short of the minimum
- and : mirror images of each other around the ideal rate, landing on the exact same final loss , by symmetry — is either way
- The exact rate lands in one step
For this quadratic, (where is the curve's steepness) satisfies — the update jumps straight to on step one and stays there. Loss , not approximately, exactly.
- Too large stalls, too much larger explodes
- gives : the update overshoots to , back to , forever — the loss never improves past its starting value of .
- pushes past : the point sails further from the minimum every step, ending 20 steps later with loss over .
Find the one learning rate, among the six candidates, that drives the loss all the way to zero.
Grid search is the least clever way to tune a hyperparameter — try everything, keep the best — and that's exactly why it works: it doesn't need to know that is special for this particular curve, only that it scored lowest. The same idea scales to any hyperparameter this course has quietly fixed by hand: in k-nearest neighbors, in DBSCAN, the number of trees in a forest. The next chapter turns to a different kind of choice — not a setting on the model, but a transformation of the data itself, before any model ever sees it.