CosineAnnealingScheduler#

class composer.optim.CosineAnnealingScheduler(t_max='1dur', alpha_f=0.0)[source]#

Decays the learning rate according to the decreasing part of a cosine curve.

See also

This scheduler is based on CosineAnnealingLR from PyTorch.

Specifically, the learning rate multiplier \(\alpha\) can be expressed as:

\[\alpha(t) = \alpha_f + (1 - \alpha_f) \times \frac{1}{2} (1 + \cos(\pi \times \tau)) \]

Given \(\tau\), the fraction of time elapsed (clipped to the interval \([0, 1]\)), as:

\[\tau = t / t_{max} \]

Where \(t_{max}\) represents the duration of this scheduler, and \(\alpha_f\) represents the learning rate multiplier to decay to.

Parameters
  • t_max (str | Time) โ€“ The duration of this scheduler. Default = "1dur".

  • alpha_f (float) โ€“ Learning rate multiplier to decay to. Default = 0.0.