3.2.6 · D4Training Deep Networks

Exercises — Learning rate scheduling

3,138 words14 min readBack to topic

This page is your self-test for Learning Rate Scheduling. Every problem states its difficulty level (L1 → L5). Try each one first, then open the collapsible solution. After every level there is one trap callout — the exact mistake most people make there.

Notation reminder (every symbol used on this page, defined here so you never need the parent open):

  • = learning rate, the size of each parameter step.
  • = starting learning rate; = the learning rate at training step or epoch .
  • = peak learning rate a schedule reaches; = floor value a schedule decays down to.
  • = step-decay multiplier, the factor () by which is multiplied at each drop.
  • = drop interval for step decay: the number of epochs between drops.
  • = decay rate for exponential () and inverse () schedules; bigger = faster decay.
  • = period (total length) of a cosine cycle; = warmup length in steps.
  • Linear warmup schedule: for the first steps the learning rate ramps up straight from to : for . Why: at step 0 the weights are random and Adam's variance estimate is unreliable, so tiny early steps prevent blow-up.
  • = the floor: the biggest whole number (e.g. ).
  • = the steady-state variance of the parameter around a minimum (how much it "buzzes"); = gradient-noise variance; = curvature of the local quadratic loss.

Prerequisite topics you may want open: Stochastic Gradient Descent, Adam and Adaptive Optimizers, Robbins-Monro Stochastic Approximation, Warm Restarts (SGDR).


Level 1 — Recognition

Recall Solution 1.1
  • (a) Step decay → 3 (the floor counts how many drops happened).
  • (b) Exponential decay → 1 (smooth curve).
  • (c) decay → 4 (denominator grows linearly in ).
  • (d) Cosine annealing → 2 (the term).

Why the floor gives a staircase: jumps up by 1 only when crosses a multiple of , so is flat between drops and then multiplies by — a staircase.

Figure s01 — the step-decay staircase. Below, the red curve is with , , . Notice three things: (1) between the dotted vertical lines the red curve is perfectly flat does not change mid-block; (2) at each multiple of epochs it drops by a factor (each arrow marks a halving); (3) the drops get smaller in absolute size because they multiply an ever-smaller number. This is the "train at a plateau, then suddenly drop to a lower basin" behaviour.

Figure — Learning rate scheduling
Recall Solution 1.2
  • At : , so .
  • At : , so .

Why memorise the endpoints: they are the two anchor points — everything else is a smooth ride between them.

Recall Solution 1.3

The inverse / decay, . Why: it behaves like for large ; the harmonic series (you can still travel arbitrarily far) while (the noise dies out).


Level 2 — Application

Recall Solution 2.1
  • WHAT: count drops. .
  • WHY: two full blocks of 20 epochs have passed (epochs 0–19, 20–39), and we are in the third block (40–59) which has had 2 drops applied.
  • .
Recall Solution 2.2
  • WHY use the half-life: after each 10 epochs halves. epochs half-lives.
  • .
  • Check algebraically: . ✔
Recall Solution 2.3
  • Since we are inside warmup, so we use the linear warmup formula .
  • .
  • Why linear up: early on Adam's second-moment estimate is tiny, so effective steps can blow up; ramping keeps them small until statistics settle.
Recall Solution 2.4
  • Halfway: .
  • .
  • This is exactly the average — but only because where .

Level 3 — Analysis

Recall Solution 3.1
  • .
  • Halve to : — exactly half.
  • WHY it halves cleanly: in the small- approximation linearly, so scaling by a factor scales by the same factor. See Robbins-Monro Stochastic Approximation for the full derivation the parent note gives.
Recall Solution 3.2
  • , so .
  • .
  • The exact value is slightly larger than the approximation .
  • WHY: the approximation drops the term, replacing by . Dividing by a bigger number () gives a smaller . So the approximation always underestimates (for ). The gap grows as grows.
Recall Solution 3.3
  • The formula expects a drop every 30 epochs steps.
  • Feeding raw steps means it drops every 30 steps instead.
  • Ratio faster decay.
  • WHY this matters: after just 30 steps has already halved; after 300 steps it is of — training effectively freezes almost immediately. Always confirm the time unit .

Level 4 — Synthesis

Recall Solution 4.1

(a) Step 1000 — inside warmup ():

(b) Step 7000 — past warmup, so we are in the cosine phase. The cosine "clock" must be reset to start at the end of warmup. Define local time and a local cosine horizon . (Here plays the role of the period from the notation reminder, but measured only over the post-warmup portion — we rename it to avoid confusing it with the total run length.) So .

  • . That is exactly halfway ().
  • .
  • .

WHY reset the cosine clock: if you used raw in , then at handoff (step 2000) the LR would jump down discontinuously instead of starting smoothly at . Shifting by makes the two pieces meet cleanly at . Look at Figure s02 — the red curve is continuous at the join.

Figure — Learning rate scheduling
Recall Solution 4.2
  • Linear scaling rule: scale by the same factor as the batch size. New .
  • WHY: a bigger batch averages over more samples, so the gradient noise variance drops by ; you can afford a larger step to keep the same effective progress per example. See Batch Size and Learning Rate scaling.
  • Add: a warmup. The now-larger can destabilise early training, so ramp up over the first few thousand steps before applying it fully.

Level 5 — Mastery

Recall Solution 5.1

A note on indexing: all sums below run over (i.e. from to ), matching the harmonic series (which starts at since is undefined).

Condition 1 (, "can travel arbitrarily far"):

  • For : — the harmonic series, which diverges to . ✔
  • For : — a finite geometric sum (since ). ✘ The geometric schedule fails Condition 1: its total step budget is bounded.

Condition 2 (, "noise dies out"):

  • For : — a -series with , which converges (to ). ✔ So decay satisfies both conditions.
  • (The geometric schedule is already disqualified by Condition 1, so its Condition-2 status is moot — though for completeness also converges, that cannot rescue it.)

Conclusion: decay passes both Robbins–Monro conditions; the geometric schedule fails the first.

Practical consequence (one sentence): because a geometric/exponential schedule can only move the parameters a bounded total distance, if the minimum lies farther than that finite budget the training stalls short of it, whereas decay can always reach any distance while still driving the residual noise to zero.

Recall Solution 5.2 (sample design + justification)

Design: linear warmup over steps ( of budget) to a peak , then cosine anneal to over the remaining steps.

  • Warmup length : long enough for Adam's second-moment estimate to stabilise, short enough not to waste budget. Why warmup at all: at step 0, so effective step can explode.
  • Cosine, not step: smooth, spends most time high (fast travel) then flattens near the end (gentle settling) — see the parent note's endpoint check.
  • : we have a fixed budget and want the tightest final fit; the noise-floor result says driving minimises residual jitter.

Values (local cosine time , horizon ):

  • Step 500 (warmup, since ): .
  • Step 5500 (cosine, ): , so .
  • Step 10000 (cosine end, ): , so .

Sanity: the schedule starts at , climbs to at step 1000, and decays smoothly to at step 10000 — continuous at every seam.

Recall Solution 5.3

Cycle lengths: , , , .

  • Restart 1 (start of cycle 1) at step .
  • Restart 2 (start of cycle 2) at step .
  • Restart 3 (start of cycle 3) at step .
  • WHY restarts help: each jump back to lets the ball hop out of a narrow basin and possibly find a wider, flatter minimum that generalises better. See Warm Restarts (SGDR).