Adam Optimizer › Bias Correction
Language AI HandbookAll chapters Adam Optimizer › Bias CorrectionOne section · Sections in this chapter4 / 18 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
There is a subtle but important flaw in the raw moment estimates. Both and are initialized to zero at step . This means that early in training, the estimates are biased toward zero. At step :
With , we have even though our best estimate of the mean gradient is itself. The true mean should be , but our estimate is only 10% of it.
This zero-initialization bias decays over time. After steps, the first moment is a weighted sum of past gradients:
Taking the expectation (assuming are drawn from the same distribution with mean ):
where:
- : the true mean gradient
- : the decay factor raised to the -th power
- : the bias factor, which starts near 0 and approaches 1 as grows
The bias factor starts at at step (meaning the estimate is only 10% of the truth) and approaches 1 as (where it becomes accurate). To correct for this initialization bias, Adam divides each moment estimate by its bias correction factor:
where:
- : the bias-corrected first moment estimate
- : the bias-corrected second moment estimate
- : correction factor for the first moment at step
- : correction factor for the second moment at step
For , the second moment bias correction is even more severe early on: , so . Without this correction, the second moment estimate is far too small for the first thousand or so steps, which would cause Adam to take enormous steps with a tiny denominator. The bias correction stabilizes training in these early steps, making Adam's behavior in the first epoch much more predictable.
As training progresses, and , so and . The correction becomes negligible after enough steps. For , the first moment correction becomes less than 1% after about steps. For , the second moment correction becomes less than 1% after about steps.
Without bias correction, you would observe a characteristic artifact at the start of training: the learning rate would appear enormous for the first few hundred steps, because the second moment estimate would be near zero, making very large. This would cause gradient explosions or wildly oscillating loss values before eventually stabilizing. With bias correction, both moments are immediately calibrated to their true statistical values, and Adam's step sizes remain reasonable from step one. This is especially important for transformer training with learning rate warmup: the warmup schedule deliberately starts with a small learning rate and increases it over the first several thousand steps. During this warmup period, the bias correction is doing exactly its intended job. Both the scheduled learning rate and the moment estimates are warming up together, creating doubly conservative early steps that prevent gradient explosions. The two mechanisms are complementary, not redundant.