mindspore/docs/api/api_python/nn/mindspore.nn.ExponentialDec...

44 lines
1.2 KiB
ReStructuredText
Raw Normal View History

2021-11-30 15:50:30 +08:00
mindspore.nn.ExponentialDecayLR
================================
.. py:class:: mindspore.nn.ExponentialDecayLR(learning_rate, decay_rate, decay_steps, is_stair=False)
基于指数衰减函数计算学习率。
2022-01-05 17:07:51 +08:00
对于当前step计算学习率的公式为
2021-11-30 15:50:30 +08:00
.. math::
2022-01-05 17:07:51 +08:00
decayed\_learning\_rate = learning\_rate * decay\_rate^{p}
2021-11-30 15:50:30 +08:00
其中,
.. math::
p = \frac{current\_step}{decay\_steps}
如果 `is_stair` 为True则公式为
.. math::
p = floor(\frac{current\_step}{decay\_steps})
**参数:**
- **learning_rate** (float): 学习率的初始值。
- **decay_rate** (float): 衰减率。
2022-01-05 17:07:51 +08:00
- **decay_steps** (int): 进行衰减的step数。
2021-11-30 15:50:30 +08:00
- **is_stair** (bool): 如果为True则学习率每 `decay_steps` 步衰减一次。默认值False。
**输入:**
2021-12-04 20:36:47 +08:00
- **global_step** (Tensor) - 当前step数。
2021-11-30 15:50:30 +08:00
**输出:**
2022-01-05 17:07:51 +08:00
标量Tensor。当前step的学习率值。
2021-11-30 15:50:30 +08:00
**异常:**
- **TypeError:** `learning_rate``decay_rate` 不是float。
- **TypeError:** `decay_steps` 不是int或 `is_stair` 不是bool。
- **ValueError:** `decay_steps` 小于1。
- **ValueError:** `learning_rate``decay_rate` 小于或等于0。