Adam Optimizer › The Adam Update Rule
Language AI HandbookAll chapters Adam Optimizer › The Adam Update RuleOne section · Sections in this chapter5 / 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
With bias-corrected moment estimates in hand, the Adam parameter update is:
where:
- : the parameter vector at step
- : the global learning rate (typically 0.001)
- : bias-corrected first moment (direction and momentum)
- : bias-corrected second moment (per-parameter scale)
- : a small constant for numerical stability, typically
The full Adam algorithm, written out step by step, is:
where:
- : the loss function
- All other variables are as defined above
The Role of Epsilon
The term in the denominator prevents division by zero when , which happens for parameters that have received no gradients. But has an additional effect on Adam's behavior that is often overlooked.
Consider a parameter where is very small, say . Then , and the effective learning rate is . This is enormous. In practice, if a parameter truly receives near-zero gradients consistently, its is also near zero, so the actual update remains small. The two small quantities cancel out.
However, if is set too small (e.g., ), numerical precision issues can cause to underflow to zero in floating-point arithmetic, resulting in infs or nans in the updates. If is set too large (e.g., 1.0), Adam degenerates toward vanilla SGD because the denominator becomes dominated by rather than , eliminating the adaptive behavior. The default is a pragmatic choice that avoids both failure modes in typical float32 computation.
PyTorch's torch.optim.Adam uses by default but exposes it as a tunable parameter. Some practitioners increase it to or even when training with mixed precision (float16), since smaller values can cause numerical instability at reduced precision.