Adam Optimizer
Adaptive optimizer combining momentum and per-parameter learning rates.
Formula
Variables
Example
Default alpha=0.001 works for most nets
How it works
Adam updates parameters by taking a step in the direction suggested by the gradient, but it first smooths that gradient with momentum and then rescales the step using an estimate of how variable each parameter’s recent gradients have been. The first moment term [1m̂m_t[0m captures the average direction, while the second moment term [1m̂v_t[0m dampens updates where gradients have been large or noisy, so unstable dimensions do not dominate the learning process. The small [1mε[0m prevents division by zero and keeps the update numerically stable.
When to use it
Use Adam when training neural networks or other differentiable models with noisy, sparse, or differently scaled gradients, especially if you want a robust default optimizer without manually tuning a separate learning rate for each parameter. It is commonly used for deep learning tasks such as image, text, and sequence models.
Worked example, step by step
Given: [1mθ = 2.00[0m, [1mα = 0.01[0m, [1m\hat{m}_t = 0.20[0m, [1m\hat{v}_t = 0.04[0m, [1mε = 0.000001[0m Step 1: Compute the denominator: [1m\sqrt{\hat{v}_t} + ε = \sqrt{0.04} + 0.000001 = 0.2 + 0.000001 = 0.200001[0m Step 2: Compute the normalized step: [1m\hat{m}_t / (\sqrt{\hat{v}_t} + ε) = 0.20 / 0.200001 \approx 0.999995[0m Step 3: Scale by the learning rate: [1mα \times (...) = 0.01 \times 0.999995 \approx 0.00999995[0m Step 4: Update the parameter: [1mθ := 2.00 - 0.00999995 = 1.99000005[0m Final answer: [1mθ [0m becomes approximately [1m1.99[0m.
Common mistakes to avoid
- Forgetting that [1m\hat{m}_t[0m and [1m\hat{v}_t[0m are bias-corrected, especially early in training
- Using [1m\hat{v}_t[0m without the square root, which changes the scale of the update
- Choosing an [1mε[0m that is too large and unintentionally dominating the denominator
Did You Know?
Adam (2015) is the default optimizer for most deep-learning models today.
Share this formula
More in Machine Learning & AI
View allLinear Regression Model
BasicPredicts a continuous value as a weighted sum of input features plus a bias.
Gradient Descent Update
BasicIteratively moves parameters in the direction that most reduces the loss.
ReLU Activation
BasicRectified Linear Unit: outputs the input if positive, else zero.
Leaky ReLU
BasicA ReLU variant that lets a small gradient flow for negative inputs.
Tanh Activation
BasicSquashes input to the range (-1, 1); zero-centred activation.
Softmax
BasicTurns a vector of scores into a probability distribution that sums to 1.