mindspore.nn.PolynomialDecayLR

class mindspore.nn.PolynomialDecayLR(learning_rate, end_learning_rate, decay_steps, power, update_decay_steps=False)[source]

Calculates learning rate base on polynomial decay function.

For the i-th step, the formula of computing decayed_learning_rate[i] is:

decayed_learning_rate[i]=(learning_rateend_learning_rate)(1tmp_step/tmp_decay_steps)power+end_learning_rate

Where :

tmp_step=min(current_step,decay_steps)

If update_decay_steps is true, update the value of tmp_decay_step every decay_steps. The formula is :

tmp_decay_steps=decay_stepsceil(current_step/decay_steps)
Parameters
  • learning_rate (float) – The initial value of learning rate.

  • end_learning_rate (float) – The end value of learning rate.

  • decay_steps (int) – A value used to calculate decayed learning rate.

  • power (float) – A value used to calculate decayed learning rate. This parameter must be greater than 0.

  • update_decay_steps (bool) – If true, learning rate is decayed once every decay_steps time. Default: False.

Inputs:

Tensor. The current step number.

Outputs:

Tensor. The learning rate value for the current step.

Examples

>>> learning_rate = 0.1
>>> end_learning_rate = 0.01
>>> decay_steps = 4
>>> power = 0.5
>>> global_step = Tensor(2, mstype.int32)
>>> polynomial_decay_lr = nn.PolynomialDecayLR(learning_rate, end_learning_rate, decay_steps, power)
>>> result = polynomial_decay_lr(global_step)
>>> print(result)
0.07363961