mindspore.nn.ExponentialDecayLR
- class mindspore.nn.ExponentialDecayLR(learning_rate, decay_rate, decay_steps, is_stair=False)[source]
- Calculates learning rate based on exponential decay function. - For current step, the formula of computing decayed learning rate is: \[decayed\_learning\_rate = learning\_rate * decay\_rate^{p}\]- Where : \[p = \frac{current\_step}{decay\_steps}\]- If is_stair is True, the formula is : \[p = floor(\frac{current\_step}{decay\_steps})\]- Parameters
 - Inputs:
- global_step (Tensor) - The current step number. \(current\_step\) in the above formula. 
 
- Outputs:
- Tensor. The learning rate value for the current step with shape \(()\). 
 - Raises
- TypeError – If learning_rate or decay_rate is not a float. 
- TypeError – If decay_steps is not an int or is_stair is not a bool. 
- ValueError – If decay_steps is less than 1. 
- ValueError – If learning_rate or decay_rate is less than or equal to 0. 
 
 - Supported Platforms:
- Ascend- GPU- CPU
 - Examples - >>> import mindspore >>> from mindspore import Tensor, nn >>> >>> learning_rate = 0.1 >>> decay_rate = 0.9 >>> decay_steps = 4 >>> global_step = Tensor(2, mindspore.int32) >>> exponential_decay_lr = nn.ExponentialDecayLR(learning_rate, decay_rate, decay_steps) >>> lr = exponential_decay_lr(global_step) >>> net = nn.Dense(2, 3) >>> optim = nn.SGD(net.trainable_params(), learning_rate=lr)