Foundations to Frontier
Tests
E. Deep Learning › E3 Optimizers (one page each)

AdaGrad

AdaGrad gives every parameter its own learning rate: the global rate divided by the square root of the sum of that parameter's past squared gradients. Parameters with large or frequent gradients slow down; rarely updated ones keep large steps. This made it the method of choice for sparse problems such as text and recommendation, and it is the ancestor of RMSProp and Adam. This page covers the update, its per-coordinate effective learning rate, its scale invariance, its regret guarantee, and its main weakness, a learning rate that only ever shrinks. In the exercises you verify its first-step and decay properties, then train logistic regression on Zipf-distributed sparse features and find that tuned AdaGrad beat tuned SGD on test loss and on weight accuracy for both rare and frequent features in every seed.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

A learning rate for every parameter

Some parameters get large, frequent gradients; others are touched only now and then, like the weight for a rare word or a rarely active sensor channel. One global learning rate either makes the busy parameters jump around or the rare ones learn too slowly. AdaGrad keeps a running total of each parameter’s squared gradients and divides that parameter’s step by its square root. Busy parameters slow down, and rare ones keep taking big steps when they finally get a signal.

Optimizer lab: AdaGrad versus plain gradient descent
AdaGrad: final loss 4.254 · gradient descent: final loss 2.2e-9 (step 22)
Orange: the chosen optimizer; grey dashed: plain gradient descent with the same learning rate. Darker shading means higher loss. On the ill-conditioned bowl, raise κ and watch gradient descent zig-zag across the narrow direction; on the saddle it stalls near the flat start; on the plateau its gradients are tiny. Adaptive methods rescale each direction; momentum methods build speed along consistent directions. The target is 1% of the starting loss (for the saddle, a loss below −0.2; its minima are at −0.25).
Why engineers care

Sparse inputs are common: one-hot categorical features (aircraft type, airport, fault code), bag-of-words features of maintenance logs, and embedding tables in recommendation systems. AdaGrad and its descendants let such models learn from rare categories without hand-tuned per-feature rates. Its per-coordinate scaling also removes much of the sensitivity to badly scaled features.

📝 Quick check (Level 0)
0/3 answered
  1. 1. AdaGrad divides each parameter's step by…
  2. 2. Rarely updated parameters under AdaGrad keep…
  3. 3. AdaGrad's effective learning rate over time…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Update: Gᵢ ← Gᵢ + gᵢ², then wᵢ ← wᵢ − η·gᵢ/(√Gᵢ + ε). Example: w = 0, G = 3, g = 1, η = 1 gives G = 4 and w = −0.5.
  • Effective learning rate: ηᵢ = η/√Gᵢ. For G = (4, 100) and η = 1: (0.5, 0.1).
  • First step: with G = 0 the first step is η·sign(gᵢ), the same size in every coordinate however different the gradients: gradients (0.1, 10) give steps (η, η).
  • Constant gradient: after t identical gradients g, the step is η/√t in size: 1/√t of the first.
  • Scale invariance: multiplying a coordinate’s gradients by a constant c multiplies √G by c too, so the step is unchanged. AdaGrad is invariant to per-coordinate rescaling of the gradient.
📝 Quick check (Level 1)
0/3 answered
  1. 1. AdaGrad's first step for gradient (0.01, 5) with η = 0.1 is…
  2. 2. Effective rate for G = 25, η = 1?
  3. 3. After 100 identical gradients the step is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

AdaGrad in code

Exercise 1.

  • The first step moves every coordinate by exactly η, regardless of gradient scale.
  • With a constant gradient the effective learning rate decays as 1/√t: 0.5 after 4 steps and 0.1 after 100.
  • On the badly scaled bowl (x² + 100y²)/2, AdaGrad reached a loss below 10⁻⁹⁰ in 200 steps, while gradient descent near its stability limit was at 2.3 × 10⁻⁴. On a diagonal quadratic, AdaGrad’s per-coordinate scaling matches the curvature.

Practice.

  • Typical η is 0.01–0.1, with ε around 10⁻¹⁰ to 10⁻⁸. Some implementations start G at a small positive value.
  • The accumulator never forgets, so in long non-convex training the effective learning rate can shrink to almost nothing before the model is trained. RMSProp (E3-6) and Adadelta (E3-5) replace the sum by a moving average.
  • AdaGrad remains strong for convex sparse problems such as linear models on one-hot or text features, and for embedding tables.
torch.optim.Adagrad(params, lr=0.05, initial_accumulator_value=0.1, eps=1e-10)
🐍 Exercise 1: AdaGrad's step and its decay
Implement the AdaGrad step and the per-coordinate effective learning rate; check the first step, the 1/√t decay, and compare with gradient descent on a badly scaled bowl.
📝 Quick check (Level 2)
0/3 answered
  1. 1. AdaGrad's main weakness in long non-convex training is…
  2. 2. Its successors that use moving averages are…
  3. 3. AdaGrad is still a strong choice for…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Online learning. Duchi, Hazan and Singer (2011) analysed AdaGrad as an online convex optimisation method. Its regret, the cumulative loss compared with the best fixed parameter in hindsight, satisfies

Regret_T ≤ O(‖w*‖_∞ · Σᵢ √(Σₜ gₜ,ᵢ²)).

For sparse gradients this can be much smaller than the O(√(dT)) bound of SGD with a single rate, because coordinates that are rarely non-zero contribute little to their own sum.

Diagonal preconditioning. AdaGrad approximates the full-matrix method that preconditions by (Σ ggᵀ)^(−1/2), keeping only the diagonal. The full-matrix version is the starting point of Shampoo (E3-17). When the loss’s curvature is aligned with the axes, the diagonal captures most of the benefit; when it is not, rotations defeat it.

Why the rate decays. For convex problems a decaying learning rate is needed for convergence (Robbins–Monro), and AdaGrad’s 1/√Σg² decay is automatic and adapted per coordinate. In non-convex deep learning, early large gradients can permanently shrink the rates of the parameters that need to keep moving.

📝 Quick check (Level 3)
0/3 answered
  1. 1. AdaGrad was introduced by…
  2. 2. AdaGrad's diagonal approximates preconditioning by…
  3. 3. Diagonal preconditioning is defeated by…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Does AdaGrad help with sparse features?

History.

  • J. Duchi, E. Hazan and Y. Singer (2011) and H. B. McMahan and M. Streeter (2010) introduced adaptive per-coordinate learning rates with regret bounds.
  • J. Dean et al. (2012) used AdaGrad to train large distributed networks (DistBelief).
  • J. Pennington, R. Socher and C. Manning (2014) trained GloVe word vectors with AdaGrad.

Exercise 2. Logistic regression over 2000 binary features. Each example activates 8 of them, drawn with Zipf-like frequencies (feature k with probability about 1/(k + 1)), so a few features are very common and most are rare. Training makes one online pass over 8000 examples with SGD or AdaGrad, each with its learning rate tuned on a grid, and test loss is measured on 20 000 new examples. Weight error is the RMS error against the true weights, for features seen more than 100 times (76 features) and features seen 3–20 times (about 1500).

seed method best η test log loss weight error, frequent weight error, rare
0 SGD 0.03 0.597 0.525 0.959
0 AdaGrad 0.3 0.511 0.289 0.796
1 SGD 0.1 0.533 0.330 0.942
1 AdaGrad 0.3 0.495 0.287 0.830
2 SGD 0.1 0.488 0.312 0.915
2 AdaGrad 0.3 0.468 0.290 0.811
  • AdaGrad won in every seed on every measure, even with SGD’s learning rate tuned.
  • Rare features learned better. Their weight error fell from 0.92–0.96 to 0.80–0.83. SGD’s single rate had to be small for the frequent features’ sake, so rare features barely moved.
  • Frequent features also learned better. AdaGrad’s per-feature decay let them settle precisely, while a fixed SGD rate kept them noisy.
  • The margin varied by seed (0.086 to 0.020 in log loss). It is largest when SGD’s best compromise rate is forced low by the frequent features.
🐍 Exercise 2 (research): does AdaGrad help with sparse features?
Train online logistic regression on Zipf-distributed sparse binary features with tuned SGD and tuned AdaGrad, and compare test log loss and the accuracy of frequent and rare features' weights over three seeds.

AdaGrad in AI, robotics and aerospace

  • Sparse tabular models: fault-code, part-number and airport one-hot features in maintenance and operations models.
  • Embedding tables: recommendation and retrieval systems with millions of rarely updated rows often use AdaGrad-style optimisers.
  • Online learning: per-feature adaptive rates suit streaming updates of models deployed on telemetry.

References

  1. J. Duchi, E. Hazan, Y. Singer (2011). “Adaptive subgradient methods for online learning and stochastic optimization.” Journal of Machine Learning Research 12.
  2. H. B. McMahan, M. Streeter (2010). “Adaptive bound optimization for online convex optimization.” Proc. COLT.
  3. J. Dean et al. (2012). “Large scale distributed deep networks.” Advances in NeurIPS 25.
  4. J. Pennington, R. Socher, C. D. Manning (2014). “GloVe: global vectors for word representation.” Proc. EMNLP.