mindspore.nn.WarmUpLR
- class mindspore.nn.WarmUpLR(learning_rate, warmup_steps)[source]
Gets learning rate warming up.
For the i-th step, the formula of computing warmup_learning_rate[i] is:
\[warmup\_learning\_rate[i] = learning\_rate * tmp\_step / warmup\_steps\]Where :
- Parameters
- Inputs:
global_step (Tensor) - The current step number.
- Outputs:
Tensor. The learning rate value for the current step with shape \(()\).
- Raises
TypeError – If learning_rate is not a float.
TypeError – If warmup_steps is not an int.
ValueError – If warmup_steps is less than 1.
ValueError – If learning_rate is less than or equal to 0.
- Supported Platforms:
Ascend
GPU
Examples
>>> learning_rate = 0.1 >>> warmup_steps = 2 >>> global_step = Tensor(2, mstype.int32) >>> warmup_lr = nn.WarmUpLR(learning_rate, warmup_steps) >>> result = warmup_lr(global_step) >>> print(result) 0.1