mindspore.nn.piecewise_constant_lr
- mindspore.nn.piecewise_constant_lr(milestone, learning_rates)[source]
Get piecewise constant learning rate.
Calculate learning rate by given milestone and learning_rates. Let the value of milestone be \((M_1, M_2, ..., M_N)\) and the value of learning_rates be \((x_1, x_2, ..., x_N)\). N is the length of milestone. Let the output learning rate be y.
\[y[i] = x_t,\ for\ i \in [M_{t-1}, M_t)\]- Parameters
- Returns
list[float]. The size of list is \(M_N\).
Examples
>>> milestone = [2, 5, 10] >>> learning_rates = [0.1, 0.05, 0.01] >>> output = piecewise_constant_lr(milestone, learning_rates) >>> print(output) [0.1, 0.1, 0.05, 0.05, 0.05, 0.01, 0.01, 0.01, 0.01, 0.01]