Cosine annealing is a learning rate scheduler that lowers the learning rate from a maximum to a minimum following half of a cosine wave. Loshchilov and Hutter proposed it in 2017 as part of SGDR (Stochastic Gradient Descent with Warm Restarts) (ICLR 2017).
The learning rate is given by the following formula (Eq. (5) in the paper).
Here, and are the maximum and minimum learning rates of the -th cycle, is the length of that cycle (in epochs), and is the number of epochs elapsed since the cycle started. advances with every mini-batch, so it also takes fractional values such as 0.1 and 0.2.
With , and , the values are as follows.
| Elapsed epochs | 0 | 2.5 | 5 | 7.5 | 10 |
|---|---|---|---|---|---|
| Learning rate | 0.050 | 0.043 | 0.025 | 0.007 | 0 |
The learning rate falls slowly at the beginning and end and quickly in the middle. This realizes the usual pattern, exploring broadly with a large learning rate early on and fine-tuning with a small one at the end, as a smooth curve without discrete steps. Only the maximum, the minimum and the length need to be chosen; unlike step decay, there is no need to decide when and by what factor to lower the rate.

