StepLR Learning Rate Scheduler

Initialization, Normalization & Regularization DS practice problem on Onlearn.

Difficulty: easy.

Topics: StepLR Learning Rate Scheduler, Step Decay, Gamma Multiplier, Step Size Interval, Epoch-based Scheduling, Learning Rate Warmup, Optimization Theory, Deep Learning Foundations, Numerical Analysis, Hyperparameter Tuning, Software Engineering for ML, Learning Rate Schedules, Gradient Descent Variants, Training Loop Orchestration, Convergence Analysis, Model State Management.

Write a Python class StepLRScheduler to implement a learning rate scheduler based on the StepLR strategy. Your class should have an init method implemented to initialize with an initial lr (float), step size (int), and gamma (float) parameter. It should also have a get lr(self, epoch) method implemented that returns the current learning rate for a given epoch (int). The learning rate should be decreased by gamma every step size epochs. The answer should be rounded to 4 decimal places. Only use standard Python.