Implement a learning rate scheduler based on the SGDR (Stochastic Gradient Descent with Warm Restarts) technique from Loshchilov & Hutter, 2017.
The scheduler uses cosine annealing to decay the learning rate from a maximum value to a minimum value within each cycle. At the end of each cycle, the learning rate "restarts" back to the maximum. The cycle length can optionally grow after each restart by a multiplicative factor.
Write a function cosine_annealing_warm_restarts(eta_max, eta_min, T_0, T_mult, total_epochs) that computes the learning rate for each epoch from 0 to total_epochs - 1.
Parameters:
eta_max (float): Maximum (initial) learning rate at the start of each cycleeta_min (float): Minimum learning rate at the end of each cycleT_0 (int): Number of epochs in the first cycleT_mult (int): Multiplicative factor for cycle length after each restart. The second cycle has length T_0 * T_mult, the third has length T_0 * T_mult^2, and so on. When T_mult is 1, all cycles have the same length T_0.total_epochs (int): Total number of epochs to compute learning rates forThe function should return a list of floats, where each float is the learning rate for the corresponding epoch, rounded to 4 decimal places.
For each epoch, you need to determine which cycle it belongs to, compute how far into that cycle it is, and apply the cosine annealing formula accordingly.