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.WarmUpLR.rst 1.2 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. mindspore.nn.WarmUpLR
  2. ======================
  3. .. py:class:: mindspore.nn.WarmUpLR(learning_rate, warmup_steps)
  4. 学习率热身。
  5. 对于当前step,计算warmup_learning_rate[current_step]的公式为:
  6. .. math::
  7. warmup\_learning\_rate[current\_step] = learning\_rate * tmp\_step / warmup\_steps
  8. 其中,
  9. .. math:
  10. tmp\_step=min(current\_step, warmup\_steps)
  11. **参数:**
  12. - **learning_rate** (float): 学习率的初始值。
  13. - **warmup_steps** (int): 学习率warmup的step数。
  14. **输入:**
  15. **global_step** (Tensor):当前step数。
  16. **输出:**
  17. Tensor。形状为 :math:`()` 的当前step的学习率值。
  18. **异常:**
  19. - **TypeError:** `learning_rate` 不是float。
  20. - **TypeError:** `warmup_steps` 不是int。
  21. - **ValueError:** `warmup_steps` 小于1。
  22. - **ValueError:** `learning_rate` 小于或等于0。
  23. **支持平台:**
  24. ``Ascend`` ``GPU``
  25. **样例:**
  26. >>> learning_rate = 0.1
  27. >>> warmup_steps = 2
  28. >>> global_step = Tensor(2, mstype.int32)
  29. >>> warmup_lr = nn.WarmUpLR(learning_rate, warmup_steps)
  30. >>> result = warmup_lr(global_step)
  31. >>> print(result)
  32. 0.1