ExponentialLR Learning Rate Scheduler

Initialization, Normalization & Regularization DS practice problem on Onlearn.

Difficulty: easy.

Topics: Understanding ExponentialLR Learning Rate Scheduler, Exponential Decay, Gamma Factor, Epoch-based Updates, Precision Rounding, Stateful Class Encapsulation, Optimization, Deep Learning Foundations, Numerical Analysis, Software Engineering, Hyperparameter Tuning, Learning Rate Scheduling, Gradient Descent Variants, Training Loop Orchestration, Floating Point Arithmetic, Object-Oriented Design.

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