You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.warmup_lr.rst 1.1 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536
  1. mindspore.nn.warmup_lr
  2. =======================
  3. .. py:function:: mindspore.nn.warmup_lr(learning_rate, total_step, step_per_epoch, warmup_epoch)
  4. 预热学习率。
  5. 对于第i步,计算warmup_learning_rate[i]的公式为:
  6. .. math::
  7. warmup\_learning\_rate[i] = learning\_rate * tmp\_epoch / warmup\_epoch
  8. 其中 :math:`tmp\_epoch=min(current\_epoch, warmup\_epoch),\ current\_epoch=floor(\frac{i}{step\_per\_epoch})`
  9. **参数:**
  10. - **learning_rate** (float) - 学习率的初始值。
  11. - **total_step** (int) - step总数。
  12. - **step_per_epoch** (int) - 每个epoch的step数。
  13. - **warmup_epoch** (int) - 预热学习率的epoch数。
  14. **返回:**
  15. list[float]。 `total_step` 表示列表的大小。
  16. **样例:**
  17. >>> import mindspore.nn as nn
  18. >>>
  19. >>> learning_rate = 0.1
  20. >>> total_step = 6
  21. >>> step_per_epoch = 2
  22. >>> warmup_epoch = 2
  23. >>> output = nn.warmup_lr(learning_rate, total_step, step_per_epoch, warmup_epoch)
  24. >>> print(output)
  25. [0.0, 0.0, 0.05, 0.05, 0.1, 0.1]