Adam (name derived from Adaptive Moment Estimation) is a machine learning algorithm for first-order gradient-based optimization that computes adaptive learning rates for each parameter.

Adam combines the advantages of two other gradient-based algorithms that maintain per-parameter learning rates, Adagrad and RMSprop with Momentum.

Adagrad works well for sparse gradients by scaling the learning rate for each parameter according to the history of gradients from previous iterations.

In RMSprop, the learning rate is adapted using the moving average of the squared gradient for each weight, making it useful for mini-batch learning in on-line settings.

There are a few small but important differences between Adam and the algorithms it is based on.

Adam differs from RMSprop with momentum in 2 ways:

- RMSprop with momentum generates its parameter updates using a momentum on the rescaled gradient, whereas Adam updates parameters with direct estimates using a running average of first and second moment of the gradient.
- Adam has a bias-correction term and RMSprop does not.

In Adagrad, the abstract function that scales learning rate for parameters is the sum of all past and current gradients. In Adam, this abstract function is the moving averages of past squared gradients.

Theberkeleyview summarized how Adam works in 5 steps:

- Compute the gradient and its element-wise square using the current parameters.
- Update the exponential moving average of the 1st-order moment and the 2nd-order moment.
- Compute an unbiased average of the 1st-order moment and 2nd-order moment.
- Compute weight update: 1st-order moment unbiased average divided by the square root of 2nd-order moment unbiased average (and scale by learning rate).
- Apply update to the weights.