Skip to content
AI360XpertBeta
Core ML

Visual explainer

Learning Rate Scheduling, Visually

A schedule changes the learning rate as training advances. Follow checked steps, warmup, cosine decay and restarts, then see why curvature still limits the rate.

Fixed rates can converge slowly or oscillate on the same objective.
Fixed rates can converge slowly or oscillate on the same objective.

A learning rate schedule changes the multiplier on an optimizer's update as training advances. It can allow larger early steps and smaller later steps; its shape alone guarantees neither convergence nor better validation performance.

Use a synthetic one-weight objective L(w)=w2L(w)=w^2, starting at w0=2w_0=2. Its gradient is 2w2w, so plain gradient descent gives wt+1=(1−2ηt)wtw_{t+1}=(1-2\eta_t)w_t, where ηt\eta_t is the rate used for update tt. There is no momentum, weight decay or sampling noise here.

The picture stacks successive weight rulers downward: rows 0, 1 and 2 are update counts, and horizontal position is the weight on identical scales. Rate 0.1 gives 2→1.6→1.282\to1.6\to1.28; rate 1 gives 2→−2→22\to-2\to2. The dashed center is the minimum at zero. This objective converges for any fixed rate strictly between 0 and 1. Fixed rates can work; scheduling adds control over how the rate changes.

Scale the Same Gradient

A smaller rate shortens the displacement for the same gradient.
A smaller rate shortens the displacement for the same gradient.

Reset to w=2w=2, with gradient 4. Each row starts at the same right-hand dot. Rates 0.1, 0.05 and 0.01 give displacements −0.4-0.4, −0.2-0.2 and −0.04-0.04, reaching weights 1.6, 1.8 and 1.96. These are alternative updates from one state, not successive steps.

The ruler is deliberately magnified to 600 SVG units per weight unit, versus 50 in the first scene. Displacement is proportional to rate when the gradient is held fixed. During a real trajectory, the gradient changes too; rate decay and shrinking gradients are separate causes of smaller steps.

Raise the Rate Gradually

Linear warmup raises the rate gradually to its chosen peak.
Linear warmup raises the rate gradually to its chosen peak.

Warmup spends an initial interval increasing the rate. This illustrative ramp is η(s)=0.02s\eta(s)=0.02s for boundary clock s=0,…,5s=0,\ldots,5: 0, 0.02, 0.04, 0.06, 0.08, 0.1. Zero marks the initial boundary; a loop using the next boundary's rate would use 0.02 on its first update. Specify that convention before coding a schedule.

Goyal et al., section 2.2 study gradual warmup for large-minibatch training, starting from a nonzero low rate. Our zero-start ramp demonstrates the shape, not their exact setup. Warmup may help when an immediately large rate is problematic; it does not bound every gradient or make an excessive peak safe.

Read a Cosine Schedule

Cosine decay reaches the middle of its rate range halfway through the horizon.
Cosine decay reaches the middle of its rate range halfway through the horizon.

Now isolate a decay phase, starting its own clock at zero. With maximum rate 0.1, minimum 0 and horizon T=8T=8, use

η(s)=0.05(1+cos⁡πs8),0≤s≤8.\eta(s)=0.05\left(1+\cos\frac{\pi s}{8}\right),\qquad 0\leq s\leq8.

The rates at boundaries 0, 2, 4, 6 and 8 are approximately 0.1, 0.08536, 0.05, 0.01464 and 0. The drawing joins samples at every integer boundary; those segments approximate the continuous cosine. Its change is slow near both ends and fastest near the middle. The guides expose the halfway value.

The official cosine scheduler documentation gives this closed form and distinguishes annealing without restarts. A warmup-plus-cosine schedule shifts the decay clock to the end of warmup. The horizon is a chosen budget, not a consequence of observing low loss.

Compute the Resulting Steps

A changing rate produces a different computed weight trajectory.
A changing rate produces a different computed weight trajectory.

Return to L(w)=w2L(w)=w^2 and w0=2w_0=2. To keep every multiplication checkable, compare a four-update linear rate sequence 0.4, 0.3, 0.2, 0.1 with a fixed rate 0.1. This is a new schedule, not the preceding cosine samples.

The scheduled weights are 2→0.4→0.16→0.096→0.07682\to0.4\to0.16\to0.096\to0.0768: for example, the second step is 0.4−0.3(0.8)=0.160.4-0.3(0.8)=0.16. The fixed-rate weights are 2→1.6→1.28→1.024→0.81922\to1.6\to1.28\to1.024\to0.8192. Solid dots and the dashed comparison share an update-count axis and a weight axis, with 90 SVG units per weight unit.

The final losses are 0.07682=0.005898240.0768^2=0.00589824 and 0.81922=0.671088640.8192^2=0.67108864. These are computed teaching values, not measured model results. A fixed rate 0.4 reaches weight 0.0032 after four updates here, outperforming this schedule. The example shows the effect of the chosen rates, not a general advantage of scheduling.

Hold, Then Drop

Step decay holds the rate constant between chosen drop boundaries.
Step decay holds the rate constant between chosen drop boundaries.

A staircase is another choice. Hold rate 0.4 for clock values 0≤s<20\leq s<2, then 0.2 for 2≤s<42\leq s<4, then 0.1 at 4. Each boundary halves the rate, following the multiplicative structure in StepLR. Open rings exclude the old value at a drop; filled dots select the new one. Dashed vertical strokes indicate jumps, not rates used between them.

The vertical axis now measures rate, at 450 SVG units per rate unit. Abrupt drops are not inherently harmful, and a smooth curve is not inherently superior. Choose the shape and boundaries using the training setup and validation evidence, rather than a universal model-family prescription.

Zero Can Stall Progress

A zero rate freezes plain SGD before it reaches the minimum.
A zero rate freezes plain SGD before it reaches the minimum.

Repeat the first rate-0.4 update: weight 2 becomes 0.4. If all remaining rates are zero, the next three weights remain 0.4, with loss 0.16, even though the gradient is still 0.8. The dashed continuation uses the remaining 0.3, 0.2 and 0.1 rates from the earlier calculation. Both traces retain that scene's weight and time scales.

This is a stall away from the minimum, not a local-minimum trap. A small nonzero rate need not stop progress, and the plain-gradient rule here does not describe every optimizer's stored state or extra update terms. Raising the rate can resume movement.

Name the Clock Unit

Calling an epoch schedule every update brings its drop forward.
Calling an epoch schedule every update brings its drop forward.

Suppose each epoch contains two optimizer updates. A planned drop after two epochs belongs after four updates. If an epoch-based counter advances on every update instead, the same drop happens after two updates, compressing its horizon by half.

Both rows use update count horizontally and identical rate heights, 0.4 before the drop and 0.2 after. An epoch is one data pass; an optimizer update changes the weights. Gradient accumulation can further separate batches from updates. Set the scheduler's call frequency and counter units explicitly. Clock errors can silently invalidate a mathematically correct curve.

The Rate Can Rise Again

A scheduled restart raises the learning rate without resetting the weights.
A scheduled restart raises the learning rate without resetting the weights.

A restart refutes the idea that decay must be irreversible. Repeat cosine phases with horizon 4, maximum 0.1 and minimum 0. The open ring at boundary 4 shows the previous phase's zero-rate limit; the filled dot is the rate 0.1 selected at the restart. Each cycle joins integer samples, with the same rate-height scale as the earlier cosine scene. The open endpoint at 8 marks the next cycle boundary.

Cosine warm restarts restart the rate clock. They do not by themselves reinitialize model weights. A renewed larger step may help exploration, but need not improve loss or recover a useful solution.

Where It Breaks

A schedule cannot make an excessive step stable on a steeper loss.
A schedule cannot make an excessive step stable on a steeper loss.

Change the objective explicitly to L(w)=5w2L(w)=5w^2, with gradient 10w10w. The horizontal axis is weight, the vertical direction is loss, and the curve is the exact quadratic, using 200 SVG units per weight unit and 40 per loss unit. This is a loss-space view, unlike the earlier weight-over-time plots.

Starting at w=0.5w=0.5, a rate of 0.3 gives wnext=0.5−0.3(5)=−1w_{next}=0.5-0.3(5)=-1. Loss rises from 1.25 to 5. The ring is the start; the amber diamond is the endpoint, with a chord showing the update across the minimum.

For this objective, contraction requires ∣1−10η∣<1|1-10\eta|<1, or 0<η<0.20<\eta<0.2. Rate 0.3 violates that condition. A later decay may eventually enter a stable range, but it cannot make this particular uphill step a descent step. Warmup, cosine and restarts still require suitable rates, a meaningful clock and evaluation on the actual problem. The deterministic one-weight fixture supplies no guarantee for neural-network generalization.

The Quick Version

  • Fixed rates can converge, crawl or oscillate depending on curvature.
  • Rate scales a displacement; gradients also change during training.
  • Warmup raises the rate toward a chosen peak.
  • Cosine decay changes fastest near its midpoint.
  • A computed trajectory is not a model-performance benchmark.
  • Step decay holds rates between chosen drop boundaries.
  • Zero rate can freeze plain SGD away from the minimum.
  • Scheduler units must match the frequency of scheduler calls.
  • Restarts raise the rate without reinitializing model weights.
  • A schedule name does not guarantee stable steps or generalization.