Skip to content
nonconvexcard

Adaptive Methods and Variance Reduction

AdaGrad, RMSProp, Adam and AdamW derived from their design goals, plus SVRG and SAGA and what each one actually guarantees.

SGDGraduate⏱ 3 hours13 min readadagradrmspropadamadamwweight decay
5 problems →

Two distinct ideas are often conflated. Adaptive methods rescale the step per coordinate using observed gradient magnitudes; they change the geometry but not the noise. Variance reduction constructs a lower-variance gradient estimator; it changes the noise but not the geometry. They address different terms in the SGD bound, and they have very different theoretical status.

AdaGrad

DefinitionAdaGrad

With Gt=∑s≤tgs⊙gsG_t = \sum_{s\le t} g_s\odot g_s accumulated coordinatewise,

xt+1,i=xt,i−ηGt,i+ϵ gt,i.x_{t+1,i} = x_{t,i} - \frac{\eta}{\sqrt{G_{t,i}}+\epsilon}\,g_{t,i}.
TheoremAdaGrad regret bound

Let f1,…,fTf_1,\dots,f_T be convex with subgradients gt∈∂ft(xt)g_t \in \partial f_t(x_t), and suppose ∥xt−x⋆∥∞≤D∞\norm{x_t - x^\star}_\infty \le D_\infty for all tt. Then AdaGrad with η=D∞/2\eta = D_\infty/\sqrt2 satisfies

∑t=1T(ft(xt)−ft(x⋆))≤2 D∞∑i=1d∑t=1Tgt,i2.\sum_{t=1}^T\big(f_t(x_t)-f_t(x^\star)\big) \le \sqrt2\,D_\infty\sum_{i=1}^d\sqrt{\sum_{t=1}^Tg_{t,i}^2}.

Key idea

The bound involves ∑i∑tgt,i2\sum_i\sqrt{\sum_t g_{t,i}^2}, not d∑t∥gt∥22\sqrt{d\sum_{t}\norm{g_t}_2^2}. For sparse gradients — most coordinates zero most of the time, as in bag-of-words features or embedding layers — the former is far smaller. That is what AdaGrad was designed for and what it provably delivers. The dense case gives no improvement over tuned SGD, and AdaGrad's monotonically growing GtG_t makes the effective step decay like 1/t1/\sqrt t whether or not that is appropriate — which is the motivation for the exponential averaging in RMSProp and Adam.

RMSProp and Adam

DefinitionAdam

With β1=0.9\beta_1 = 0.9, β2=0.999\beta_2 = 0.999 typically,

mt=β1mt−1+(1−β1)gt,m^t=mt1−β1t,vt=β2vt−1+(1−β2) gt⊙gt,v^t=vt1−β2t,xt+1=xt−η m^tv^t+ϵ.\begin{aligned} m_t &= \beta_1 m_{t-1} + (1-\beta_1)g_t, &\qquad \hat m_t &= \frac{m_t}{1-\beta_1^t},\\ v_t &= \beta_2 v_{t-1} + (1-\beta_2)\,g_t\odot g_t, &\qquad \hat v_t &= \frac{v_t}{1-\beta_2^t},\\ x_{t+1} &= x_t - \eta\,\frac{\hat m_t}{\sqrt{\hat v_t}+\epsilon}. && \end{aligned}

RMSProp is Adam with β1=0\beta_1 = 0 and no bias correction.

Why the bias correction is what it is

  1. mt=(1−β1)∑s=1tβ1t−sgs.m_t = (1-\beta_1)\sum_{s=1}^t \beta_1^{t-s}g_s .

    Unroll the exponential moving average from m_0 = 0.

  2. Emt=(1−β1) Eg∑s=1tβ1t−s=Eg (1−β1t).\E m_t = (1-\beta_1)\,\E g\sum_{s=1}^t\beta_1^{t-s} = \E g\,\big(1-\beta_1^t\big).

    Take expectations assuming the gradient distribution is stationary with mean g.

  3. Em^t=Eg\E \hat m_t = \E g. The same computation gives Ev^t=E[g⊙g]\E\hat v_t = \E[g\odot g].

    The estimator is biased towards zero by exactly the factor (1 − β₁ᵗ), so dividing by it removes the bias.

  4. 1−β2t→11-\beta_2^t \to 1 geometrically, so the correction is negligible after a few thousand steps.

    The correction matters only early: at t = 1 with β₂ = 0.999 the uncorrected v₁ is a thousand times too small, so the uncorrected step would be about thirty times too large.

TheoremAdam can fail to converge

There is a sequence of convex functions ftf_t with bounded gradients on a bounded convex domain, and a choice of β1,β2\beta_1,\beta_2 satisfying the conditions stated in the original Adam paper, for which Adam's average regret does not tend to zero.

Quoted from Reddi, Kale and Kumar. The counterexample is a one-dimensional problem where a large informative gradient arrives every third step and small misleading gradients arrive in between; the exponential average vtv_t forgets the large gradient before it can be acted on, so the effective step in the informative direction is persistently too small. The proposed fix, AMSGrad, replaces vtv_t with a running maximum, restoring the monotonicity that AdaGrad had and Adam gave up.

What this does not say

The theorem does not say Adam does not work. It says the convergence proof in the original paper is wrong, and that no such proof can exist under those hypotheses. Adam works extremely well on the problems it is used for; AMSGrad, which has a proof, is not noticeably better in practice. The honest statement is that Adam's empirical success is not currently explained by a convergence theorem, and convergence guarantees for it exist only under additional assumptions (bounded gradients plus β1<β2\beta_1 < \sqrt{\beta_2}, or a decaying β2\beta_2 schedule).

AdamW: why decoupling matters

PropositionL2 regularisation and weight decay differ under adaptive preconditioning

Consider adding λx\lambda x to the gradient (L2 regularisation) versus subtracting ηλx\eta\lambda x from the update (weight decay). Under SGD the two coincide. Under a diagonal preconditioner PtP_t they do not: the first gives

xt+1=xt−ηPt(gt+λxt),x_{t+1} = x_t - \eta P_t\big(g_t + \lambda x_t\big),

the second gives

xt+1=xt−ηPtgt−ηλxt.x_{t+1} = x_t - \eta P_t g_t - \eta\lambda x_t .

The effective shrinkage in the first is ηλPt\eta\lambda P_t, which varies by coordinate.

Key idea

Under Adam, Pt,ii=1/(v^t,i+ϵ)P_{t,ii} = 1/(\sqrt{\hat v_{t,i}}+\epsilon), so L2 regularisation applies weaker shrinkage to coordinates with large gradient variance — the opposite of what a regulariser is supposed to do, since those are exactly the parameters most at risk of overfitting noise. Decoupling the decay (AdamW) makes the shrinkage uniform and, empirically, substantially improves generalisation. This is a case where a purely mathematical observation about operator ordering had a large practical effect, and it is worth keeping as a reminder that "L2L_2 penalty" and "weight decay" are only synonyms for unpreconditioned methods.

Variance reduction

The noise floor ησ2/μ\eta\sigma^2/\mu comes from σ2>0\sigma^2>0. For a finite sum f=1n∑ifif = \frac1n\sum_i f_i the variance can be reduced to zero at the optimum, using a control variate.

Algorithm — SVRG (stochastic variance reduced gradient)
  1. Outer loop. At epoch ss, set the snapshot x~=x(s)\tilde x = x^{(s)} and compute the full gradient μ~=∇f(x~)\tilde\mu = \nabla f(\tilde x) once, at cost nn.
  2. Inner loop. For k=1,…,mk = 1,\dots,m: sample ii uniformly and take xk+1=xk−η(∇fi(xk)−∇fi(x~)+μ~).x_{k+1} = x_k - \eta\big(\nabla f_i(x_k) - \nabla f_i(\tilde x) + \tilde\mu\big).
  3. Restart. Set x(s+1)x^{(s+1)} to (an average of) the inner iterates and repeat.
PropositionThe SVRG estimator is unbiased with vanishing variance

The inner-loop direction is unbiased, and its variance is bounded by

E∥∇fi(xk)−∇fi(x~)+μ~−∇f(xk)∥22≤2L2(∥xk−x⋆∥22+∥x~−x⋆∥22),\E\norm{\nabla f_i(x_k)-\nabla f_i(\tilde x)+\tilde\mu - \nabla f(x_k)}_2^2 \le 2L^2\left(\norm{x_k - x^\star}_2^2 + \norm{\tilde x - x^\star}_2^2\right),

so it tends to zero as both the iterate and the snapshot approach x⋆x^\star.

TheoremSVRG attains a linear rate on finite sums

For μ\mu-strongly convex ff with each fif_i being LL-smooth, SVRG with suitable η\eta and m=Θ(L/μ)m = \Theta(L/\mu) satisfies E[f(x(s))−f⋆]≤ρs(f(x(0))−f⋆)\E\big[f(x^{(s)})-f^\star\big]\le \rho^s\big(f(x^{(0)})-f^\star\big) for some ρ<1\rho<1, at a total gradient cost of O((n+L/μ)log⁡(1/ε))O\big((n + L/\mu)\log(1/\eps)\big).

Quoted from Johnson and Zhang. Compare the alternatives for the same problem: full gradient descent costs O(nκlog⁡(1/ε))O(n\kappa\log(1/\eps)) and SGD costs O(1/(με))O(1/(\mu\eps)). SVRG's O((n+κ)log⁡(1/ε))O((n+\kappa)\log(1/\eps)) beats both — an additive rather than multiplicative dependence on nn and κ\kappa. SAGA achieves the same with a gradient table instead of periodic full passes.

Empirical observationVariance reduction does not help deep learning in practice

Empirical observation — a regularity seen in experiments. No theorem on this page establishes it in general.

Despite the clean theory, SVRG and SAGA have not produced wall-clock improvements on large neural networks, and are not used.

What this does not say

Defazio and Bottou investigated this directly and identified several reasons, none of which is a flaw in the theorems:

  • Data augmentation makes the objective not a finite sum — each "example" is a distribution, so there is no fixed ∇fi\nabla f_i to snapshot.
  • Batch normalisation and dropout make ∇fi\nabla f_i depend on the rest of the batch and on fresh randomness, again breaking the finite-sum structure.
  • The snapshot goes stale fast. The theory assumes ∥xk−x~∥2\norm{x_k-\tilde x}_2 stays small; in deep learning the iterate moves far within an epoch, so the control variate has little correlation with the gradient it is correcting and the variance reduction largely evaporates.
  • Memory. SAGA's gradient table is O(nd)O(nd), which is impossible at scale.

This is a good example of a gap between theory and practice where the theory is correct and the hypotheses are what fail. Identifying which hypothesis fails is more useful than concluding that theory does not apply.

Problems

The AdaGrad summation inequalityProof · Advanced · 30 min Derive Adam's bias correctionProof · Beginner · 15 min Why AdamW differs from Adam with L2Proof · Intermediate · 30 min The SVRG control variateProof · Advanced · 1 hour

References

These works are cited as sources to read, not reproduced. All exposition, examples and problems on this site are written independently; where an argument is standard, the citation points to a canonical treatment.

Results stated on this page

Problems (5)

All problems

Papers that use this mathematics