Course map
Stage 1: Foundations
Stage 2: Machine Learning
Stage 3: Deep Learning
Stage 4: LLMs & Generative AI
Stage 5: Production & Specialization

Part 11 / Topic 2 of 6

The learning rate

No other number changes outcomes this much. Measured on a linear-regression toy (50 steps each):

# examples/01_learning_rate_too_small_is_slow.py (abridged)
for lr in [0.001, 0.1, 0.9, 1.5]:
    print(f"lr={lr:<6} loss after 50 steps = {train(lr):.4g}")
# lr=0.001 loss after 50 steps = 5.912 <- crawling
# lr=0.1 loss after 50 steps = 0.005468 <- fine
# lr=0.9 loss after 50 steps = 3.199e-10 <- fast
# lr=1.5 loss after 50 steps = 3.169e+29 <- diverged

Four orders of input, thirty-nine orders of output. Search in powers of 10, watch the loss curve, and remember the signatures: flat-and-slow = too small; spiky or exploding = too large. Schedules (decay the rate over training, often after a short warmup) squeeze out the last quality once the right ballpark is found.

🧪 Quick quiz

  1. With learning rate 1.5 on the course example, what happened?
Show the answer

The loss exploded to about 3e+29 — divergence. 0.001 was still at 5.912 after 50 steps (too slow); 0.9 converged fast.

Done here? The practice set for Part 11 — 4 exercises with solutions — is on the part page.

Search the guide