Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindformers.core.CosineAnnealingWarmRestarts

View Source On Gitee
class mindformers.core.CosineAnnealingWarmRestarts(base_lr: float, t_0: int, t_mult: int = 1, eta_min: float = 0., **kwargs)[source]

Set the learning rate of each parameter group using a cosine annealing schedule, where ηmax is set to the initial lr, Tcur is the number of epochs since the last restart and Ti is the number of epochs between two warm restarts in SGDR:

ηt=ηmin+12(ηmaxηmin)(1+cos(TcurTiπ))

When Tcur=Ti, set ηt=ηmin. When Tcur=0 after restart, set ηt=ηmax.

It has been proposed in SGDR: Stochastic Gradient Descent with Warm Restarts .

Parameters
  • base_lr (float) – Initial value of learning rate.

  • t_0 (int) – Number of iterations for the first restart.

  • t_mult (int, optional) – A factor increases Ti after a restart. Default: 1.

  • eta_min (float, optional) – Minimum learning rate. Default: 0.

Inputs:
  • global_step (int) - The global step.

Outputs:

Learning rate.

Examples

>>> import mindspore as ms
>>> from mindformers.core import CosineAnnealingWarmRestarts
>>>
>>> ms.set_context(mode=ms.GRAPH_MODE)
>>> base_lr = 0.005
>>> t_0 = 10
>>> t_mult = 2
>>> eta_min = 0.0000001
>>>
>>> cosine_annealing_restart = CosineAnnealingWarmRestarts(base_lr=base_lr,
...                                                        t_0=t_0,
...                                                        t_mult=t_mult,
...                                                        eta_min=eta_min)
>>> print(cosine_annealing_restart(1))
0.0048776437
>>> print(cosine_annealing_restart(15))
0.0042677815