mindspore/docs/api/api_python/nn/mindspore.nn.CosineDecayLR.rst

35 lines
963 B
ReStructuredText
Raw Normal View History

2021-11-30 15:50:30 +08:00
mindspore.nn.CosineDecayLR
===========================
.. py:class:: mindspore.nn.CosineDecayLR(min_lr, max_lr, decay_steps)
基于余弦衰减函数计算学习率。
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 = &min\_lr + 0.5 * (max\_lr - min\_lr) *\\
2021-12-27 23:16:04 +08:00
&(1 + cos(\frac{current\_step}{decay\_steps}\pi))
2021-11-30 15:50:30 +08:00
**参数:**
- **min_lr** (float): 学习率的最小值。
- **max_lr** (float): 学习率的最大值。
2022-01-05 17:07:51 +08:00
- **decay_steps** (int): 进行衰减的step数。
2021-11-30 15:50:30 +08:00
**输入:**
2022-02-14 10:42:17 +08:00
- **global_step** (Tensor) - 当前step数即current_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
**异常:**
2022-02-11 15:23:20 +08:00
- **TypeError** - `min_lr``max_lr` 不是float。
- **TypeError** - `decay_steps` 不是整数。
- **ValueError** - `min_lr` 小于0或 `decay_steps` 小于1。
- **ValueError** - `max_lr` 小于或等于0。