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

Learning Rate Tuning

Practical guidance for tuning the single most consequential hyperparameter in deep learning โ€” building on the conceptual foundation from Learning Rate.

Typical Starting Ranges, by Optimizer

OptimizerTypical Starting Range
SGD (with momentum)0.01 โ€“ 0.1
Adam / AdamW1e-4 โ€“ 1e-3
Fine-tuning a pretrained model1e-5 โ€“ 1e-4 (much smaller โ€” see Fine-Tuning)

The Learning Rate Range Test โ€” A Practical Technique

Rather than guessing, a systematic approach: start training with a very small learning rate, and gradually increase it (often exponentially) over a short number of steps, plotting loss against learning rate. The loss typically decreases as the learning rate rises to a useful range, then sharply increases once the learning rate becomes too large for stable training โ€” the ideal learning rate sits just before that sharp increase.

Code โ€” A Simple Learning Rate Range Test

import torch
import matplotlib.pyplot as plt

def lr_range_test(model, train_loader, loss_fn, start_lr=1e-7, end_lr=1, num_steps=100):
    optimizer = torch.optim.Adam(model.parameters(), lr=start_lr)
    lr_mult = (end_lr / start_lr) ** (1 / num_steps)
    lrs, losses = [], []

    for i, (x, y) in enumerate(train_loader):
        if i >= num_steps:
            break
        optimizer.zero_grad()
        loss = loss_fn(model(x), y)
        loss.backward()
        optimizer.step()

        lrs.append(optimizer.param_groups[0]['lr'])
        losses.append(loss.item())
        optimizer.param_groups[0]['lr'] *= lr_mult   # exponentially increase LR each step

    plt.plot(lrs, losses)
    plt.xscale('log')
    plt.xlabel('Learning Rate'); plt.ylabel('Loss')
    # pick a learning rate from just before the loss starts sharply increasing

Diagnosing From Symptoms

SymptomLikely Cause
Loss decreases extremely slowlyLearning rate too low
Loss oscillates wildly or diverges (becomes NaN)Learning rate too high
Loss plateaus early, higher than expectedCould be too high (stuck oscillating near a minimum) or too low (hasn't reached it yet) โ€” try both directions

Common Mistakes

  • Never adjusting the learning rate from a copied default, regardless of the specific model/dataset โ€” while the typical ranges above are reasonable starting points, the truly optimal value genuinely varies by task and is worth verifying.
  • Confusing a too-high learning rate's symptoms with a fundamentally broken model architecture โ€” always rule out learning rate first, since its symptoms (oscillating or diverging loss) can look similar to other, more structural problems.

Interview Relevance

Q: "How would you systematically find a good learning rate for a new model, rather than guessing?" A learning rate range test โ€” gradually increasing the learning rate over a short warmup run while tracking loss, then plotting loss against learning rate on a log scale. The loss typically decreases through a useful range, then sharply increases once the rate becomes destabilizingly large; picking a rate just before that sharp increase is a reliable, systematic starting point.

Practice Question

If a model's loss decreases very slowly over many epochs but never oscillates or spikes, is the learning rate more likely too high or too low?

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 Tuning โ€“ FAQs

Quick answers about learning Learning Rate Tuning in Deep Learning.

This free note from CodingNow 2.0 explains Learning Rate Tuning 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 Tuning, is 100% free with no signup required.
With focused practice, most students grasp Learning Rate Tuning 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