Recommended resources
The freely available resources this lesson will direct you to.
- Who's Adam and What's He Optimizing? | Deep Dive into Optimizers for Machine Learning!www.youtube.com
- Stanford CS231N | Spring 2025 | Lecture 3: Regularization and Optimizationwww.youtube.com
- Chapter 27: Momentum, RMSProp, and Adam — Classical Foundations of Artificial Neural Networksbnaskrecki.faculty.wmi.amu.edu.pl
- Adam, AdaGrad, RMSprop: Adaptive Learning Rates | TensorTonicwww.tensortonic.com
Introduction
In our last lesson, we explored how momentum-based methods improve upon Stochastic Gradient Descent (SGD) by smoothing out the optimization path and accelerating convergence. We saw that by incorporating a "velocity" term—an exponentially weighted moving average of past gradients—we could navigate the narrow, high-curvature valleys of the loss landscape more effectively. However, both SGD and its momentum-based variants still rely on a single, global learning rate applied uniformly to all model parameters.
This lesson tackles that limitation. We will investigate adaptive learning rate methods, a class of optimizers that compute an individual, per-parameter learning rate. The learning objective is to describe how RMSProp and Adam function as these adaptive methods and to compare their tradeoffs. We will see how they elegantly solve problems that a single learning rate cannot, and why Adam, in particular, has become the de facto standard optimizer for a vast range of deep learning applications.
The Problem: A Single Learning Rate for All
In complex neural networks, not all parameters are created equal. Some parameters may be associated with very frequent features in the data, receiving strong, consistent gradient updates. Others might correspond to rare, sparse features, for which gradients are infrequent and potentially noisy.
Consider a natural language processing model learning word embeddings. The parameter updates for a common word like "the" will be frequent and large, while updates for a rare word like "sesquipedalian" will be few and far between.
- If we set a high global learning rate, we risk the updates for "the" becoming too large, causing oscillations and instability.
- If we set a low global learning rate, the parameters for "the" might converge nicely, but the parameters for "sesquipedalian" will barely update, and the model will fail to learn its meaning.
This motivates the core idea of adaptive methods: what if we could automatically adjust the learning rate for each parameter, slowing it down for parameters with consistently large gradients and speeding it up for those with small or infrequent gradients?
Adam, AdaGrad, RMSprop: Adaptive Learning Rates | TensorTonic
This article from TensorTonic provides an excellent, high-level introduction to the motivation behind adaptive learning rates.
Please read the introduction and the section "The Problem with Global Learning Rate" up to the heading "The Solution". Focus on the core insight and the concrete word embedding example.
RMSProp: Fixing a Fatal Flaw
The first widely-used adaptive method was AdaGrad (Adaptive Gradient). Its strategy is to scale each parameter's update inversely proportional to the square root of the sum of all its past squared gradients. This means parameters with a history of large gradients get a smaller effective learning rate. While brilliant for sparse data, AdaGrad has a critical issue for deep learning: the sum of squared gradients in the denominator only ever increases. Over time, this causes the learning rate to shrink towards zero, prematurely halting the training process.
RMSProp (Root Mean Square Propagation), proposed by Geoffrey Hinton, provides an elegant fix. Instead of accumulating a sum of all past squared gradients, RMSProp maintains an exponentially weighted moving average (EWMA) of them. This "leaky" accumulator adapts to the most recent gradient information, preventing the learning rate from monotonically decaying to zero.
The algorithm at step for a single parameter is:
- Compute the gradient:
- Update the moving average of squared gradients, :
- Update the parameter :
Here:
- is the master learning rate.
- is the decay rate for the moving average (e.g., 0.9).
- is a small constant (e.g., ) to prevent division by zero.
The term is the "Root Mean Square" of recent gradients that gives the algorithm its name. This term normalizes the gradient: if recent gradients have been large, the denominator is large and the effective step size is small. If recent gradients have been small, the denominator is small and the effective step size is large.
The following video lecture explains this mechanism in detail.
Stanford CS231N | Spring 2025 | Lecture 3: Regularization and Optimization
This segment from a Stanford CS231N lecture clearly explains the mechanics of RMSProp.
Watch the section on RMSProp starting from this timestamp. Pay close attention to how the lecturer explains the update rule, especially the role of the grad_squared term in the denominator. The key intuition is that this term leads to larger steps in flatter directions and shorter steps in steep directions, which directly addresses the oscillation problem in narrow loss valleys.
This adaptive behavior is visualized in the image below. In a loss landscape with a narrow valley (steep in the b direction, flat in the w direction), RMSProp dampens the oscillations along the steep b axis and accelerates progress along the flatter w axis, finding a much more direct path to the minimum than standard gradient descent.

Adam: Adaptive Moment Estimation
So far, we've seen two major improvements to SGD:
- Momentum: Accumulates a moving average of past gradients to accelerate in consistent directions. This is an estimate of the first moment (the mean) of the gradients.
- RMSProp: Accumulates a moving average of past squared gradients to adapt the per-parameter learning rate. This is an estimate of the second moment (the uncentered variance).
Adam (Adaptive Moment Estimation), proposed by Kingma and Ba, brilliantly combines these two ideas into a single, powerful optimizer. It maintains two separate moving averages: one for the gradients themselves (like momentum) and another for the squared gradients (like RMSProp).
The algorithm proceeds as follows:
- Compute gradient:
- Update first moment estimate (momentum):
- Update second moment estimate (RMSProp):
However, there's a problem. Since and are initialized to zero, in the early steps of training, and are biased towards zero. Adam introduces a crucial bias correction step to counteract this.
- Compute bias-corrected moment estimates:
- Update parameter:
The default hyperparameters are typically , , and .
The following reading provides a detailed walkthrough of the Adam algorithm and the rationale for its design.
Chapter 27: Momentum, RMSProp, and Adam — Classical Foundations of Artificial Neural Networks
This section from "Classical Foundations of Artificial Neural Networks" provides a thorough, mathematical explanation of the Adam optimizer.
Please read the entire section 27.4. Focus on understanding how Adam integrates the first and second moments. Pay special attention to the subsection "Why Bias Correction?", which derives the correction factor and explains its importance, especially in the early stages of training. For a CS PhD like yourself, the provided implementation in section 3 of the source, AdamOptimizer, might also be insightful as it maps the equations directly to code.
Tradeoffs and Practical Considerations
Adam's combination of momentum and adaptive learning rates makes it incredibly effective and robust across a wide range of problems. It is often the default choice for training deep neural networks.

Despite its strengths, Adam is not a silver bullet, and understanding its tradeoffs is crucial for advanced practice.
Generalization vs. Convergence Speed
While Adam converges very quickly, some research has shown that for certain tasks, particularly in computer vision, models trained with SGD+Momentum can achieve slightly better generalization performance on the test set. The theory is that the "noisier" path of SGD helps it settle into "flatter" minima, which are thought to generalize better than the "sharper" minima that Adam might find.
Adam and Regularization: The Rise of AdamW
A critical discovery was that the standard implementation of L2 regularization interacts poorly with adaptive optimizers like Adam. In SGD, adding an L2 penalty to the loss is equivalent to applying weight decay directly to the weights. In Adam, this equivalence breaks. The regularization term in the gradient also gets scaled by the adaptive denominator , meaning parameters with large historical gradients receive less effective regularization.
AdamW (Adam with Decoupled Weight Decay) fixes this. It "decouples" the weight decay from the gradient update. The optimization step is performed using only the gradients from the loss function, and then a separate weight decay step is applied.
- Adam with L2:
- AdamW:
This seemingly small change has a significant impact, often leading to better model performance and making AdamW the standard for training state-of-the-art models, especially Transformers.
Who's Adam and What's He Optimizing? | Deep Dive into Optimizers for Machine Learning!
This video provides a great visual summary and comparison of the optimizers we've discussed.
First, watch the section on RMSProp, which provides an excellent animation of how it navigates a narrow valley. Then, watch the main section on Adam, which explains its combination of momentum and adaptive rates, including a good animation of escaping a local minimum. Finally, the section on benchmarks shows practical comparisons on real-world datasets like Fashion-MNIST and CIFAR-10, reinforcing the performance differences we've discussed.
Conclusion
In this lesson, we have moved from a single, global learning rate to sophisticated, per-parameter adaptive methods. We've traced the evolution of these ideas from the flawed AdaGrad to the robust and powerful Adam optimizer.
Your key takeaways are:
- Adaptive learning rates adjust the step size for each parameter individually, which is crucial for training on data with sparse features and for navigating complex, ill-conditioned loss landscapes.
- RMSProp improves upon AdaGrad by using an exponentially weighted moving average of squared gradients, preventing the learning rate from decaying to zero. It scales updates inversely to the root-mean-square of recent gradients.
- Adam combines the adaptive learning rate mechanism of RMSProp (the second moment) with the velocity of momentum (the first moment). It also introduces a critical bias-correction step to account for the zero-initialization of the moment estimates.
- Tradeoffs: While Adam is a powerful and robust default, it's important to be aware of its potential generalization tradeoffs compared to SGD+Momentum and the critical distinction between L2 regularization and decoupled weight decay, which is correctly handled by AdamW.
We now have a solid understanding of the most important optimization algorithms used in modern deep learning. In our next lesson, we will shift our focus to other essential techniques for successfully training deep networks, starting with dropout, a powerful regularization method, and batch normalization, which helps stabilize the training process.