Linear Learning Rate Decay

Calculus & Optimization DS practice problem on Onlearn.

Difficulty: medium.

Topics: Understanding Linear Learning Rate Decay, Linear Interpolation (LERP), Step-wise Decay Scheduling, Clipping Constraints, Epoch-based Progress Calculation, Non-negative Constraint Enforcement, Optimization Theory, Calculus, Numerical Analysis, Deep Learning Fundamentals, Stochastic Gradient Descent, Learning Rate Scheduling, Gradient Descent Dynamics, Hyperparameter Tuning, Convergence Analysis, Time-based Decay Functions.

Implement a function linear lr decay(current step, total steps, initial lr, end lr) that computes the current learning rate. The learning rate should start at initial lr and decay linearly to end lr over total steps. If current step exceeds total steps, the learning rate should remain at end lr. If current step is negative, it should return initial lr.