Introduction
The Adam optimizer is a cornerstone of modern deep learning, prized for its efficiency and adaptive capabilities. However, practitioners frequently encounter a significant hurdle: Adam's inherent instability during the initial stages of training. To combat this, a "warmup" heuristic—starting with a very low learning rate and gradually increasing it—is commonly employed. In their ICLR 2020 paper, Liu et al. provide a theoretical explanation for this phenomenon and introduce Rectified Adam (RAdam), an optimizer designed to stabilize training automatically by managing the variance of the adaptive learning rate.
The Problem: Early-Stage Variance
The authors identify that the instability in adaptive optimizers like Adam stems from the extreme variance of the adaptive learning rate when it is calculated from a limited number of initial samples. In the first few steps of training, the moving average of squared gradients lacks sufficient history, leading to unreliable updates.
As illustrated in the figure above, without warmup, the adaptive learning rate distribution becomes heavily distorted within the first ten updates. This "early-stage chaos" can push model parameters into suboptimal regions of the loss landscape from which recovery is difficult. Warmup serves as a manual method to suppress these high-variance updates until the optimizer's estimates stabilize.
Methods: The Rectification Mechanism
Moving beyond heuristics, the researchers modeled the adaptive term as a scaled inverse chi-square distribution. Their analysis proved that at the very beginning of training, the variance of the adaptive learning rate is effectively infinite. To resolve this, they proposed a rectification term ($r_t$) that scales the learning rate based on the "degrees of freedom" ($ ho_t$) of the gradient moving average.
The RAdam algorithm functions in two phases:
- Low Certainty Phase ($\rho_t \leq 4$): When the variance estimate is unreliable, the optimizer disables the adaptive component and operates similarly to SGD with momentum.
- High Certainty Phase ($\rho_t > 4$): As more data is processed and certainty increases, the optimizer transitions into a fully adaptive mode, using the rectification factor to maintain consistent variance.
Key Results
RAdam was validated across diverse tasks, including image classification (ResNet), language modeling (LSTM), and neural machine translation (Transformer). The results consistently showed that RAdam provides the stability of manual warmup without the need for hyperparameter tuning.
In experiments on the IWSLT’14 dataset (Figure 1), vanilla Adam failed to converge effectively, while RAdam achieved a low training loss identical to that of Adam with a carefully tuned warmup. Furthermore, RAdam demonstrated superior robustness to the initial learning rate, maintaining performance across a much wider range of values than vanilla Adam.
Conclusion
RAdam represents a significant step forward in optimizer design by replacing a common heuristic with a mathematically grounded solution. By automatically rectifying the variance of the adaptive learning rate, it simplifies the training process for complex models like Transformers and ensures more robust convergence across various deep learning domains.
Summary updated