๐Ÿ”ฅLimited Offer: Get 50% OFFon AI & Full Stack Courses๐Ÿ”ฅ
Back to Deep Learning Notes
Topic #97

Learning Rate

The learning rate \(\eta\) is widely considered the single most important hyperparameter in deep learning โ€” it controls how large a step every weight takes on every update, and getting it wrong can prevent training from working at all, regardless of architecture or data quality.

Where It Appears

\[ \mathbf{w}_{t+1} = \mathbf{w}_t - \eta\nabla L(\mathbf{w}_t) \]

\(\eta\) scales the gradient before it's subtracted โ€” a larger \(\eta\) means bigger, faster (but riskier) steps; a smaller \(\eta\) means smaller, safer (but slower) steps.

Typical Ranges in Practice

OptimizerTypical Starting Learning Rate
SGD (with momentum)0.01 โ€“ 0.1
Adam / AdamW0.0001 โ€“ 0.001 (often written 1e-4 to 1e-3)
Fine-tuning a pretrained modelMuch smaller โ€” 1e-5 to 1e-6, to avoid destroying pretrained weights

These are starting points, not universal answers โ€” the right value depends on the specific architecture, batch size, and optimizer, which is exactly why hyperparameter tuning (covered in its own category later) exists.

Revisiting the Too-Small / Good / Too-Large Picture

The three-way comparison from Gradient Descent (Intro) is worth restating precisely here: too small wastes training time without necessarily reaching a better solution; too large causes the loss to oscillate or diverge outright, since each step can overshoot the minimum by more than the previous step's progress; a well-chosen learning rate balances fast progress against stable convergence.

Numerical Illustration

import torch

def try_lr(lr, steps=20):
    w = torch.tensor(10.0, requires_grad=True)   # start far from the minimum at w=0
    for _ in range(steps):
        loss = w ** 2
        loss.backward()
        with torch.no_grad():
            w -= lr * w.grad
        w.grad.zero_()
    return w.item()

print("lr=0.01: ", try_lr(0.01))    # converges slowly, still far from 0
print("lr=0.3:  ", try_lr(0.3))     # converges nicely toward 0
print("lr=1.1:  ", try_lr(1.1))     # diverges -- overshoots and grows without bound

Learning Rate and Batch Size Interact

A larger mini-batch (see Mini-Batch Gradient Descent) produces a less noisy, more "confident" gradient estimate โ€” a common practical heuristic ("linear scaling rule") is to increase the learning rate roughly proportionally when increasing the batch size, though this isn't a universal law and should be validated empirically for a given setup.

Common Mistakes

  • Using the same fixed learning rate across the entire training run by default โ€” as covered later in this category, scheduling the learning rate (decaying it over time, or warming it up at the start) often meaningfully improves final performance.
  • Diagnosing a diverging loss as a data or architecture problem before checking the learning rate first โ€” an overly aggressive learning rate is one of the most common root causes of a loss that explodes or oscillates wildly.

Interview Relevance

Q: "Your model's training loss is oscillating wildly and occasionally spiking to very large values. What's the first hyperparameter you'd check?" The learning rate โ€” this exact symptom (oscillation, occasional spikes, sometimes outright divergence) is the classic signature of a learning rate set too high, causing weight updates to overshoot the loss surface's minimum repeatedly rather than converging toward it.

Practice Question

You're fine-tuning a large pretrained model on a small new dataset. Would you expect to use a larger or smaller learning rate than training a similar-sized model from scratch? Why?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course โ€” live mentorship, real projects, and 100% placement support.

Enroll Now โ€” Free Demo Available

Learning Rate โ€“ FAQs

Quick answers about learning Learning Rate in Deep Learning.

This free note from CodingNow 2.0 explains Learning Rate in Deep Learning โ€” concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including Learning Rate, is 100% free with no signup required.
With focused practice, most students grasp Learning Rate in 1โ€“3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) โ€” expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now