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
  • learning_rate (float) – The initial value of learning rate.

  • warmup_steps (int) – The warm up steps of learning rate.

Inputs:

Tensor. The current step number.

Outputs:

Tensor. The learning rate value for the current step.

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