A learning rate that's perfect once training has settled down is often wildly too large at the very first step, while everything is still far from where it needs to be. One fixed number can't be right for both moments.
This toy problem just wants to minimize starting from . The base rate here is deliberately too large to use constantly. Watch over 12 steps — it doesn't wobble, it climbs, forever.
Two schedules address this from different angles. Step decay reduces the rate at fixed checkpoints:
Warmup + cosine instead starts the rate at (near) zero and ramps it up before easing it back down:
- — the base (peak) learning rate.
- — the step-decay shrink factor applied every steps.
- — the number of warmup steps, ramping linearly from up to .
- — the total number of training steps, by which the cosine term reaches its floor.
- Step decay still starts at the full (too-large) rate
Until the first checkpoint at , — exactly the same too-large rate as never decaying at all. Whatever damage a too-large rate does in those first steps still happens.
- Warmup never applies the full rate until x has already moved toward the optimum
, and it only reaches at — by which point gradient descent has already taken several small, safe steps. The large rate arrives once it's less likely to cause an overshoot.
Switch between all three. Step decay eventually gets the loss down too — but only after a huge overshoot in the middle, while it's still using the full base rate. Warmup + cosine reaches a comparably tiny final loss without ever letting the loss climb above where it started.
- Constant: diverges immediately and never recovers
At the base rate, — each step grows in magnitude by 40%. Since every step multiplies by the same , this is a plain geometric sequence: . At : , and the loss — up from at the start.
- Step decay: the same explosion, temporarily
For the first 4 steps (before the first decay), step decay is identical to constant, so the same closed form applies: , and loss — nearly its starting value, before the rate ever drops. Once it does, the trajectory recovers quickly and the final loss ends up tiny — but only after that mid-run spike.
- Warmup + cosine: no spike at all
During warmup, is a different rate every step, so each step needs its own multiplication:
- : , so — completely unchanged
- : , so
- : , so
- : , so
By the time the rate ramps up to its peak at , has already shrunk to on its own from those small early steps. The loss never exceeds its starting value of anywhere along the run, and still ends near .
Pick the schedule that gets the loss under 0.01 by step 12 and never lets the loss climb above its own starting value along the way.
A constant learning rate has to compromise between "large enough to make progress" and "small enough not to overshoot" for every step of training at once — usually failing at both once the ideal rate changes over time. Step decay fixes the long run but not the start. Warmup fixes the start; cosine decay fixes the end. Together they let the rate be small when the network can't yet handle anything larger, large once it can, and small again for fine convergence — which is exactly why a flat rate is the exception in modern training, not the rule. The next chapter turns to a different training-time constraint: numeric precision itself.