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.3 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. mindspore.nn.warmup_lr
  2. =======================
  3. .. py:function:: mindspore.nn.warmup_lr(learning_rate, total_step, step_per_epoch, warmup_epoch)
  4. 预热学习率。每个step的学习率将会被存放在一个列表中。
  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. - **TypeError:** `learning_rate` 不是float。
  18. - **TypeError:** `total_step` 或 `step_per_epoch` 或 `decay_epoch` 不是int。
  19. - **ValueError:** `learning_rate` 小于0。
  20. **样例:**
  21. >>> import mindspore.nn as nn
  22. >>>
  23. >>> learning_rate = 0.1
  24. >>> total_step = 6
  25. >>> step_per_epoch = 2
  26. >>> warmup_epoch = 2
  27. >>> output = nn.warmup_lr(learning_rate, total_step, step_per_epoch, warmup_epoch)
  28. >>> print(output)
  29. [0.0, 0.0, 0.05, 0.05, 0.1, 0.1]