
Source: Adagrad and Adadelta Optimizer: In-Depth Explanation | by Vijay Sharma | Medium
Introduction
AdaDelta is an adaptive learning rate optimization algorithm proposed as an extension to RMSProp, aiming to address its main limitation: the aggressive, monotonically decreasing learning rate. It was introduced in the 2012 paper “ADADELTA: An Adaptive Learning Rate Method” by Matthew Zeiler.
RMSProp dynamically adjusts learning rates based on a window of accumulated past gradients, rather than the entire gradient history, allowing it to continue learning even in the later stages of training.
Source: “ADADELTA: An Adaptive Learning Rate Method” by Matthew Zeiler.
How AdaDelta Works
Instead of relying solely on an exponentially decaying average of past squared gradients like RMSProp, AdaDelta further maintains an additional decaying average of squared parameter updates, enabling more adaptive and unit-consistent step sizes.
Update Equations:
- Accumulate gradient history:
- Compute update step:
- Accumulate update history:
- Parameter update:
Intuition Behind AdaDelta
AdaDelta introduces a key refinement over RMSProp by not only considering the magnitude of recent gradients but also incorporating the history of parameter updates to determine the appropriate step size. This dual consideration allows the optimizer to be more adaptive and stable. In RMSProp, the parameter update is computed as:
While RMSProp adaptively scales the learning rate for each parameter using an exponentially decaying average of squared gradients, it still relies on a manually defined global learning rate $\eta$. Moreover, the units of the update step do not necessarily match the units of the parameter, potentially causing inconsistency in updates.
AdaDelta improves upon this by removing the dependence on a global learning rate and ensuring unit consistency in the update step. Its update rule is given by:
This formulation introduces two moving averages:
- $E[g^2]_t$: an exponentially decaying average of past squared gradients
- $E[\Delta \theta^2]_t$: an exponentially decaying average of past squared updates
This ratio serves as an adaptive learning rate that evolves over time based on both the recent gradient behavior and how the parameters have changed. Intuitively:
- If past updates have been large, the numerator increases → allowing larger steps now.
- If recent gradients have been steep, the denominator increases → shrinking the step size for stability. This design ensures that step sizes are both self-regulating and unit-aware, eliminating the need for manual tuning of the learning rate.
Initialization in AdaDelta
Before performing any updates, AdaDelta needs to maintain two running averages:
- $E[g^2]_t$ – the exponentially decaying average of squared gradients
- $E[\Delta \theta^2]_t$ – the exponentially decaying average of squared parameter updates
These are typically initialized to zero vectors of the same shape as the model parameters. This initialization is safe because the algorithm uses a small constant $\epsilon$ (e.g., $1e^{-6}$) to avoid division by zero in the early steps. Over time, these running averages are updated and begin to reflect the actual gradient and update magnitudes.
Example Step-by-Step (Simplified Scalar Case)
Let’s assume a scalar parameter $\theta = 1.0$ and an initial gradient $g_1 = 2.0$. Also let:
- $\rho = 0.9$
- $\epsilon = 1e^{-6}$
- $E[g^2]_0 = 0$
- $E[\Delta \theta^2]_0 = 0$
Step 1: Accumulate gradient history
Step 2: Compute update step
Step 3: Accumulate update history
Step 4: Update parameter
Code Example
This code demonstrates how to use AdaDelta to optimize a simple feedforward neural network in PyTorch. The model consists of two fully connected layers with a ReLU activation in between. AdaDelta is configured with default settings (rho=0.9, eps=1e-6), which control the decay rate of the moving averages and numerical stability, respectively.
import torch
import torch.nn as nn
import torch.optim as optim
# Define a simple neural network
model = nn.Sequential(
nn.Linear(784, 128),
nn.ReLU(),
nn.Linear(128, 10)
)
# Define loss function
criterion = nn.CrossEntropyLoss()
# Define AdaDelta optimizer
optimizer = optim.Adadelta(model.parameters(), rho=0.9, eps=1e-6)
# Dummy input and target
x = torch.randn(64, 784) # Batch of 64 images
y = torch.randint(0, 10, (64,)) # Random targets
# Training step
optimizer.zero_grad()
output = model(x)
loss = criterion(output, y)
loss.backward()
optimizer.step()Advantages of AdaDelta
- No need to manually set a learning rate. It adapts automatically based on the ratio of past updates and gradients, eliminating the need to tune a global learning rate.
- Avoids the learning rate decay problem of AdaGrad. Instead of accumulating all past gradients (which causes learning rates to vanish), it uses an exponentially decaying average to maintain learning capacity over time.
- Works well on online and streaming data. Since it dynamically adjusts to new data, it’s suitable for non-stationary problems where data distributions change over time.
- Performs consistently across many tasks without much hyperparameter tuning. The default settings (e.g., rho=0.9, epsilon=1e-6) generally work well, reducing the need for task-specific tuning.
Disadvantages of AdaDelta
- May be slower to converge compared to newer optimizers like Adam. It is because it doesn’t incorporate momentum explicitly and relies only on the update history, it might take longer to reach optimal performance.
- Less interpretable since learning rates are implicit. Unlike SGD or RMSProp where learning rate is directly visible and adjustable, AdaDelta’s internal adaptation makes it harder to analyze or debug learning behavior.
- In some deep learning tasks, it underperforms compared to Adam or RMSProp – especially in large-scale or highly non-convex problems, where other optimizers with momentum and adaptive mechanisms tend to generalize better.
When to Use AdaDelta
Use AdaDelta when:
- An adaptive learning rate is needed without manual tuning. AdaDelta automatically adjusts learning rates based on historical gradients and updates, making it suitable for scenarios with limited tuning time.
- The task involves online learning or non-stationary data. AdaDelta performs well when gradient distributions shift over time, making it ideal for streaming or sequential tasks.
- A robust, low-maintenance optimizer is preferred. With few hyperparameters and solid default values, AdaDelta reduces the complexity of training setup and is less sensitive to parameter choices.
Avoid AdaDelta when:
- Faster convergence is essential for deep models. In practice, AdaDelta may converge more slowly than newer optimizers, which incorporate momentum and more aggressive adaptation strategies.
Video Resources
- The video by IIT Madras provides a detailed explanation of the AdaDelta optimization algorithm, covering its motivation, update rules, and advantages over earlier methods like AdaGrad and RMSProp. (Runtime: 20 mins)
Related Articles:
