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

Step Decay

Step decay is the simplest and most widely understood learning rate schedule: keep the learning rate constant for a fixed number of epochs, then drop it suddenly by a fixed factor, and repeat.

Formula

\[ \eta_t = \eta_0 \cdot \gamma^{\lfloor t/s\rfloor} \]

\(s\) is the step size (how many epochs between drops), \(\gamma\) is the decay factor (e.g. 0.5 to halve, or 0.1 for a 10x drop), and \(\lfloor t/s\rfloor\) counts how many complete "steps" of \(s\) epochs have passed.

Numerical Example

With \(\eta_0=0.1\), \(s=10\), \(\gamma=0.5\): epochs 0โ€“9 use \(\eta=0.1\); epochs 10โ€“19 use \(\eta=0.1\times0.5=0.05\); epochs 20โ€“29 use \(\eta=0.1\times0.25=0.025\); and so on โ€” a clean halving every 10 epochs.

Graph

A staircase pattern โ€” constant for a fixed interval, then a sudden drop, repeated.

Code

import torch.optim as optim
from torch.optim.lr_scheduler import StepLR

optimizer = optim.SGD(model.parameters(), lr=0.1)
scheduler = StepLR(optimizer, step_size=10, gamma=0.5)

for epoch in range(30):
    # ... training loop for this epoch ...
    scheduler.step()
    print(scheduler.get_last_lr())   # [0.1]*10, then [0.05]*10, then [0.025]*10

Common Mistakes

  • Choosing a step size and decay factor without watching validation loss โ€” the "right" schedule is data-dependent; a common practical approach is to drop the learning rate specifically when validation loss plateaus, rather than at a rigid, pre-fixed schedule.
  • Using too aggressive a decay factor (e.g. \(\gamma=0.01\)) โ€” this can effectively freeze learning almost entirely after the first drop, wasting the remaining training budget.

Interview Relevance

Q: "What's a potential downside of step decay's sudden drops compared to a smoother schedule like cosine annealing?" The abrupt drop can cause a brief, noticeable jump in the loss curve right at the drop point, since the optimizer's step size suddenly changes rather than adapting gradually โ€” smoother schedules avoid this discontinuity, though step decay's simplicity and interpretability remain genuine advantages.

Practice Question

With \(\eta_0=0.2\), \(s=5\), \(\gamma=0.1\), what is the learning rate at epoch 12?

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

Step Decay โ€“ FAQs

Quick answers about learning Step Decay in Deep Learning.

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