How Learning Rate Scheduling Works (with PyTorch Examples)

Learning Rate Scheduling. Left: Illustration of SGD optimization with a typical learning rate schedule. The model converges to a minimum at the end of training. Right: Illustration of Snapshot Ensembling. The model undergoes several learning rate annealing cycles, converging to and escaping from multiple local minima.
Title: Learning Rate Scheduling. Left: Illustration of SGD optimization with a typical learning rate schedule. The model converges to a minimum at the end of training. Right: Illustration of Snapshot Ensembling. The model undergoes several learning rate annealing cycles, converging to and escaping from multiple local minima.
Source: Paper titled “Snapshot Ensembles: Train 1, Get M for Free by Gao et al.

What is Learning Rate Scheduling?

Learning Rate Scheduling is a training technique in machine learning where the learning rate is adjusted after each training step. It controls the size of the parameter updates during optimization, directly influencing both convergence speed and training stability. A learning rate that is too large may cause training to diverge or oscillate, while a learning rate that is too small can lead to extremely slow learning or convergence to poor solutions.

Different phases of training benefit from different learning rates. Early in training, a larger learning rate helps the optimizer make rapid progress and explore the loss landscape. Later in training, a smaller learning rate allows for fine-grained updates, improving convergence to a local minimum and enhancing generalization performance. Learning rate schedulers automate this adjustment process, reducing the need for manual tuning and often leading to better final model performance.

Different Learning Rate Schedulers

Illustrative Learning Rate Paths of Different Schedulers

Title: Illustrative Learning Rate Paths of Different Schedulers
Source: AIML.com Research

1. Step Decay (StepLR)

Step decay reduces the learning rate by a fixed factor after a specified number of epochs or a certain number of iterations. This creates a staircase-shaped schedule where the learning rate remains constant for several epochs and then suddenly drops.It is simple and effective for many CNN-based models where training length is known in advance. However, it requires manual tuning of the step size.

Python
from torch.optim import Adam
from torch.optim.lr_scheduler import StepLR

optimizer = Adam(model.parameters(), lr=1e-3)
scheduler = StepLR(optimizer, step_size=10, gamma=0.1)

for epoch in range(50):
    train_one_epoch(model, train_loader, optimizer)
    scheduler.step()

2. Multi-Step Decay (MultiStepLR)

Multi-step decay is a variation of step decay where the learning rate is reduced at specific, pre-defined epochs (milestones). This provides finer control over when learning rate drops occur. It is common in classic deep learning models and when milestone epochs are known from prior experiments.

Python
from torch.optim.lr_scheduler import MultiStepLR

optimizer = Adam(model.parameters(), lr=1e-3)
scheduler = MultiStepLR(optimizer, milestones=[30, 60, 90], gamma=0.1)

for epoch in range(100):
    train_one_epoch(model, train_loader, optimizer)
    scheduler.step()

3. Exponential Decay (ExponentialLR)

Exponential decay continuously reduces the learning rate by multiplying it with a constant factor at each epoch. Unlike step-based methods, this decay is smooth rather than abrupt. It is best used when a gradual and predictable reduction in learning rate is desired. On the downside, it may require fine tuning of the decay rate parameters in order to optimize convergence speed and stability.  

Python
from torch.optim.lr_scheduler import ExponentialLR

optimizer = Adam(model.parameters(), lr=1e-3)
scheduler = ExponentialLR(optimizer, gamma=0.95)

for epoch in range(50):
    train_one_epoch(model, train_loader, optimizer)
    scheduler.step()

4. Cosine Annealing (CosineAnnealingLR)

Cosine annealing adjusts the learning rate using a cosine function, producing smooth decreases rather than abrupt drops. In variants such as cosine annealing with warm restarts, the learning rate periodically increases and then decreases, unlike most traditional schedulers that only decay the learning rate. These temporary increases encourage exploration by allowing the optimizer to escape shallow local minima or flat regions of the loss landscape. By balancing exploration with gradual convergence, cosine-based schedules often lead to better optimization and generalization performance.

Python
from torch.optim.lr_scheduler import CosineAnnealingLR

optimizer = Adam(model.parameters(), lr=1e-3)
scheduler = CosineAnnealingLR(optimizer, T_max=50, eta_min=1e-5)

for epoch in range(50):
    train_one_epoch(model, train_loader, optimizer)
    scheduler.step()

5. Reduce on Plateau (ReduceLROnPlateau)

Reduce on Plateau monitors a validation metric (typically validation loss) and reduces the learning rate when improvement stalls. Unlike other schedulers, it is performance-driven rather than time-driven, and responds to actual training progress rather than following a time schedule. It is useful when training dynamics are unpredictable or the optimal schedule is unknown, but it requires careful monitoring of validation metrics and may react slowly to fine-tuning.

Python
from torch.optim.lr_scheduler import ReduceLROnPlateau

optimizer = Adam(model.parameters(), lr=1e-3)
scheduler = ReduceLROnPlateau(optimizer, mode="min", factor=0.5, patience=2)

for epoch in range(50):
    train_one_epoch(model, train_loader, optimizer)
    val_loss = evaluate(model, val_loader)
    scheduler.step(val_loss)

Which to Pick

The effect of different learning rates on reaching the minimum point
Title: The effect of different learning rates on reaching the minimum point
Source: Setting the learning rate of your neural network

Choosing a learning rate scheduler depends on the problem, model architecture, and training constraints. Each schedule has its pros and cons depending on specific needs. In practice, cosine-based schedules and one-cycle policies are good choices for well-structured training regimes, while step-based methods remain useful for reproducibility and simplicity. ReduceLROnPlateau provides a complementary, performance-driven alternative by adapting the learning rate in response to stagnating validation metrics, making it particularly useful when training dynamics are uncertain or difficult to predict. Regardless of the scheduler chosen, monitoring the learning rate during training is essential to ensure the schedule behaves as expected.

Conclusion

Learning rate scheduling is a fundamental component of effective neural network training, directly influencing both optimization efficiency and final model performance. By adjusting the learning rate throughout training, schedulers help balance rapid early learning with stable convergence in later stages. While different schedulers impose different assumptions about training dynamics, understanding their behaviors enables more informed and intentional choices. Step-based methods offer simplicity and reproducibility, cosine-based schedules provide smooth transitions and improved exploration, and metric-driven approaches such as ReduceLROnPlateau adapt dynamically to training progress. Ultimately, selecting an appropriate learning rate scheduler should be treated as an important design decision, guided by empirical evaluation and continuous monitoring.

Video Explanation

  • This video “Learning Rates and Learning Rate Schedulers“ by Lightning AI provides a good overview of learning rates and different schedulers. (Runtime: 3 min)
YouTube video
Learning Rates and Learning Rate Schedulers by Lighting AI
  • This video “Learning Rate Decay”  by Andrew Ng explains learning rate decay and various learning rate methods. (Runtime: 7 mins)
YouTube video
Learning Rate Decay (C2W2L09) by Andrew Ng (DeepLearningAI)

Author

  • MS in Computer Science at Columbia University

    Machine Learning Researcher

Help us improve this post by suggesting in comments below:

– modifications to the text, and infographics
– video resources that offer clear explanations for this question
– code snippets and case studies relevant to this concept
– online blogs, and research publications that are a “must read” on this topic

Leave the first comment

Partner Ad
Find out all the ways that you can
Contribute