mindspore.nn.exponential_decay_lr

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

Calculates learning rate base on exponential decay function.

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

\[decayed\_learning\_rate[i] = learning\_rate * decay\_rate^{\frac{current\_epoch}{decay\_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 = 1
>>> output = exponential_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, decay_epoch)
>>> print(output)
[0.1, 0.1, 0.09000000000000001, 0.09000000000000001, 0.08100000000000002, 0.08100000000000002]