Adam Optimizer › Bias Correction

Michael BrenndoerferApril 24, 20253 min read
Language AI HandbookAll chapters
Part 10 of 67Neural Network Foundations
Chapter 68Adam Optimizer › Bias Correction
Reading section 4 of 18 · Bias Correction · 3 minSection 4 of 18 · 3 min

Book contents

Section 4 of 18 · 3 min read

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 mtm_t and vtv_t are initialized to zero at step t=0t=0. This means that early in training, the estimates are biased toward zero. At step t=1t=1:

m1=β1⋅0+(1−β1)g1=(1−β1)g1m_1 = \beta_1 \cdot 0 + (1 - \beta_1) g_1 = (1 - \beta_1) g_1

With β1=0.9\beta_1 = 0.9, we have m1=0.1⋅g1m_1 = 0.1 \cdot g_1 even though our best estimate of the mean gradient is g1g_1 itself. The true mean should be g1g_1, but our estimate is only 10% of it.

This zero-initialization bias decays over time. After tt steps, the first moment is a weighted sum of past gradients:

mt=(1−β1)∑i=1tβ1t−igim_t = (1 - \beta_1) \sum_{i=1}^{t} \beta_1^{t-i} g_i

Taking the expectation (assuming gig_i are drawn from the same distribution with mean μ\mu):

E[mt]=μ⋅(1−β1t)\mathbb{E}[m_t] = \mu \cdot (1 - \beta_1^t)

where:

  • μ\mu: the true mean gradient
  • β1t\beta_1^t: the decay factor raised to the tt-th power
  • (1−β1t)(1 - \beta_1^t): the bias factor, which starts near 0 and approaches 1 as tt grows

The bias factor (1−β1t)(1 - \beta_1^t) starts at 1−0.9=0.11 - 0.9 = 0.1 at step t=1t=1 (meaning the estimate is only 10% of the truth) and approaches 1 as t→∞t \to \infty (where it becomes accurate). To correct for this initialization bias, Adam divides each moment estimate by its bias correction factor:

m^t=mt1−β1t\hat{m}_t = \frac{m_t}{1 - \beta_1^t} v^t=vt1−β2t\hat{v}_t = \frac{v_t}{1 - \beta_2^t}

where:

  • m^t\hat{m}_t: the bias-corrected first moment estimate
  • v^t\hat{v}_t: the bias-corrected second moment estimate
  • 1−β1t1 - \beta_1^t: correction factor for the first moment at step tt
  • 1−β2t1 - \beta_2^t: correction factor for the second moment at step tt

For β2=0.999\beta_2 = 0.999, the second moment bias correction is even more severe early on: 1−0.9991=0.0011 - 0.999^1 = 0.001, so v^1=v1/0.001=1000⋅v1\hat{v}_1 = v_1 / 0.001 = 1000 \cdot v_1. 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, β1t→0\beta_1^t \to 0 and β2t→0\beta_2^t \to 0, so m^t→mt\hat{m}_t \to m_t and v^t→vt\hat{v}_t \to v_t. The correction becomes negligible after enough steps. For β1=0.9\beta_1 = 0.9, the first moment correction becomes less than 1% after about t=46t = 46 steps. For β2=0.999\beta_2 = 0.999, the second moment correction becomes less than 1% after about t=4,600t = 4,600 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 vtv_t would be near zero, making α/vt\alpha / \sqrt{v_t} 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.