mindspore/docs/api/api_python/nn/mindspore.nn.PolynomialDeca...

47 lines
1.6 KiB
ReStructuredText
Raw Normal View History

mindspore.nn.PolynomialDecayLR
2021-12-04 15:18:50 +08:00
====================================
.. py:class:: mindspore.nn.PolynomialDecayLR(learning_rate, end_learning_rate, decay_steps, power, update_decay_steps=False)
基于多项式衰减函数计算学习率。
2022-01-05 17:07:51 +08:00
对于当前step计算学习率的公式为
2021-12-04 15:18:50 +08:00
.. math::
2022-01-05 17:07:51 +08:00
decayed\_learning\_rate = &(learning\_rate - end\_learning\_rate) *\\
2021-12-27 23:16:04 +08:00
&(1 - tmp\_step / tmp\_decay\_steps)^{power}\\
&+ end\_learning\_rate
2021-12-04 15:18:50 +08:00
其中,
.. math::
tmp\_step=min(current\_step, decay\_steps)
如果 `update_decay_steps` 为true则每 `decay_steps` 更新 `tmp_decay_step` 的值。公式为:
.. math::
tmp\_decay\_steps = decay\_steps * ceil(current\_step / decay\_steps)
**参数:**
2021-12-04 20:36:47 +08:00
- **learning_rate** (float) - 学习率的初始值。
- **end_learning_rate** (float) - 学习率的最终值。
2022-01-05 17:07:51 +08:00
- **decay_steps** (int) - 进行衰减的step数。
- **power** (float) - 多项式的幂必须大于0。
2021-12-04 20:36:47 +08:00
- **update_decay_steps** (bool) - 如果为True则学习率每 `decay_steps` 次衰减一次。默认值False。
2021-12-04 15:18:50 +08:00
**输入:**
2022-02-14 10:42:17 +08:00
- **global_step** Tensor当前step数即current_step。
2021-12-04 15:18:50 +08:00
**输出:**
2022-01-05 17:07:51 +08:00
标量Tensor。当前step的学习率值。
2021-12-04 15:18:50 +08:00
**异常:**
2021-12-04 20:36:47 +08:00
- **TypeError** - `learning_rate`, `end_learning_rate``power` 不是float。
- **TypeError** - `decay_steps` 不是int或 `update_decay_steps` 不是bool。
- **ValueError** - `end_learning_rate` 小于0或 `decay_steps` 小于1。
- **ValueError** - `learning_rate``power` 小于或等于0。