mindspore.nn.natural_exp_decay_lr

mindspore.nn.natural_exp_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, decay_epoch, is_stair=False)[source]

Calculate learning rate base on natural exponential decay function.

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

\[decayed\_learning\_rate[i] = learning\_rate * e^{-decay\_rate * current\_epoch}\]

Where \(current\_epoch=floor(\frac{i}{step\_per\_epoch})\).

Parameters
  • learning_rate (float) – The initial value of learning rate.

  • decay_rate (float) – The decay rate.

  • total_step (int) – The total number of steps.

  • step_per_epoch (int) – The number of steps in per epoch.

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

  • is_stair (bool) – If true, learning rate is decayed once every decay_epoch times. Default: False.

Returns

list[float]. The size of list is total_step.

Examples

>>> learning_rate = 0.1
>>> decay_rate = 0.9
>>> total_step = 6
>>> step_per_epoch = 2
>>> decay_epoch = 2
>>> output = natural_exp_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, decay_epoch, True)
>>> print(output)
[0.1, 0.1, 0.1, 0.1, 0.016529888822158657, 0.016529888822158657]