Tutorials › Statistical Learning (Graduate) › Optimistic Online Learning With Predictable Gradients

Online Regret and Batch Conversion · Tutorial 384 of 989

Optimistic Online Learning With Predictable Gradients

Learn how predictable gradient forecasts change the online gradient update and lead to a regret bound governed by cumulative squared forecast errors.

Advanced 12 min read

What You'll Learn

  • Define a predictable gradient forecast and distinguish it from the gradient observed after a decision.
  • Derive the optimistic update using a forecast sequence and an auxiliary gradient sequence.
  • Prove a pathwise regret bound in terms of squared forecast errors.
  • Translate the linearized bound into regret for convex losses.
  • Work through examples with exact, inaccurate, and model-based gradient forecasts.
  • Recognize why a small forecast error is useful even when gradients themselves are large.

Why Forecast the Gradient?

In online convex optimization, a learner chooses an action, then receives information about the loss incurred at that action. Standard gradient descent uses the gradient from the previous round to choose the next action. When successive gradients are similar, that previous gradient may already be a useful forecast of the next one. Optimistic online learning makes this idea explicit: the learner supplies a forecast before acting, and the update responds to the difference between the forecast and the gradient that is eventually observed.

The key consequence is a regret guarantee that depends on forecast error, not just on the size of the gradients. This can improve the bound when gradients are large but predictable. We derive the result for an unconstrained Euclidean action space, where the update and its proof are especially transparent.

Definition: At round \(t\), a predictable gradient forecast \(m_t\in\mathbb{R}^d\) is selected using information available before the round-\(t\) loss is revealed. In a sequential protocol with filtration \((\mathcal{F}_t)\), this means \(m_t\) is \(\mathcal{F}_{t-1}\)-measurable. The actual gradient \(g_t\) is revealed after the learner chooses \(x_t\). The forecast error is \(g_t-m_t\).

The measurability condition expresses the timing requirement: \(m_t\) cannot use information from the current loss that has not yet been observed. The regret inequality below is pathwise, so once the actions, forecasts, and gradients are specified, it holds without a probabilistic assumption on how they were generated.

The Optimistic Gradient Update

Maintain an auxiliary point \(y_t\), initialized at \(y_0\). Given a positive learning rate \(\eta\), use the forecast to choose the action and the observed gradient to update the auxiliary point:

$$ x_t = y_{t-1}-\eta m_t, \qquad y_t = y_{t-1}-\eta g_t. $$

The action \(x_t\) is chosen before observing \(g_t\). After the loss is revealed, \(y_t\) is updated using that gradient. Thus \(y_t\) is the point the learner would have reached by applying a gradient step from \(y_{t-1}\), while \(x_t\) is the point reached by substituting the forecast \(m_t\). Their difference is

$$ x_t-y_t=\eta(g_t-m_t). $$

This identity makes the design intuitive: when the forecast is accurate, the action is close to the gradient-updated auxiliary point. It also identifies the quantity that will appear in the regret bound. In practice, a forecast might be the previous observed gradient, or a prediction from a model built using past information; it must still be available before the current decision.

Worked Example: Forecasts for a Sequence of Linear Losses

Consider one-dimensional linear losses \(\ell_t(x)=g_t x\), initial point \(y_0=0\), learning rate \(\eta=1\), gradients \(g_1=1\), \(g_2=-1\), and forecasts \(m_1=1\), \(m_2=0\). Compute the actions, auxiliary points, and regret against \(u=0\).

At round 1, \(x_1=0-1(1)=-1\), and after observing \(g_1=1\), \(y_1=0-1(1)=-1\). The forecast error is \(g_1-m_1=0\).

At round 2, \(x_2=-1-1(0)=-1\), and after observing \(g_2=-1\), \(y_2=-1-1(-1)=0\). The forecast error is \(g_2-m_2=-1\).

The learner’s cumulative loss is \(g_1x_1+g_2x_2=(1)(-1)+(-1)(-1)=0\). The comparator \(u=0\) has cumulative loss zero, so regret is \(0\). The cumulative squared forecast error is \(0^2+(-1)^2=1\), and the bound proved below gives \(0\leq \eta(1)/2=0.5\), as required.

A Regret Bound in Terms of Forecast Error

For a fixed comparator \(u\in\mathbb{R}^d\), define linearized regret by \(\sum_{t=1}^T\langle g_t,x_t-u\rangle\). The next result is a pathwise inequality for any sequence of forecasts and gradients. In particular, it does not require the forecasts to be accurate; accuracy only makes the resulting bound smaller.

Theorem: Let \(y_0\in\mathbb{R}^d\), let \(\eta>0\), and generate \(x_t,y_t\) by the optimistic gradient update for \(t=1,\ldots,T\). For every comparator \(u\in\mathbb{R}^d\),
$$ \sum_{t=1}^T \langle g_t,x_t-u\rangle \leq \frac{\|u-y_0\|^2}{2\eta} + \frac{\eta}{2}\sum_{t=1}^T\|g_t-m_t\|^2. $$

Proof. From the update, \(x_t=y_{t-1}-\eta m_t\) and \(y_t=y_{t-1}-\eta g_t\). Expanding the squared distance to \(u\) gives

$$ \|u-y_{t-1}\|^2-\|u-y_t\|^2 = 2\eta\langle g_t,y_{t-1}-u\rangle-\eta^2\|g_t\|^2. $$

Also,

$$ \eta\langle g_t,x_t-u\rangle = \eta\langle g_t,y_{t-1}-u\rangle -\eta^2\langle g_t,m_t\rangle. $$

Subtracting half the expanded distance difference from this last expression yields

$$ \eta\langle g_t,x_t-u\rangle -\frac{\|u-y_{t-1}\|^2-\|u-y_t\|^2}{2} = \frac{\eta^2}{2}\|g_t\|^2-\eta^2\langle g_t,m_t\rangle. $$

The identity \(\|g_t-m_t\|^2=\|g_t\|^2-2\langle g_t,m_t\rangle+\|m_t\|^2\) shows that

$$ \frac{\eta^2}{2}\|g_t\|^2-\eta^2\langle g_t,m_t\rangle \leq \frac{\eta^2}{2}\|g_t-m_t\|^2, $$

because the right side minus the left side is \(\eta^2\|m_t\|^2/2\geq 0\). Therefore, for each round,

$$ \langle g_t,x_t-u\rangle \leq \frac{\|u-y_{t-1}\|^2-\|u-y_t\|^2}{2\eta} +\frac{\eta}{2}\|g_t-m_t\|^2. $$

Summing over \(t\), the distance terms telescope to \(\big(\|u-y_0\|^2-\|u-y_T\|^2\big)/(2\eta)\). Dropping the nonpositive term \(-\|u-y_T\|^2/(2\eta)\) proves the result. \(\square\)

If each \(\ell_t\) is convex and \(g_t\in\partial\ell_t(x_t)\), the subgradient inequality gives \(\ell_t(x_t)-\ell_t(u)\leq\langle g_t,x_t-u\rangle\). Consequently, the theorem also bounds ordinary loss regret:

$$ \sum_{t=1}^T\bigl(\ell_t(x_t)-\ell_t(u)\bigr) \leq \frac{\|u-y_0\|^2}{2\eta} + \frac{\eta}{2}\sum_{t=1}^T\|g_t-m_t\|^2. $$

This conversion uses convexity at the played action \(x_t\); it does not require the losses to be linear. If the comparator is at distance \(R=\|u-y_0\|\) and the cumulative squared forecast error is \(S=\sum_{t=1}^T\|g_t-m_t\|^2\), then for \(R>0\) and \(S>0\), choosing \(\eta=R/\sqrt{S}\) makes the displayed bound \(R\sqrt{S}\). The learning rate balances the initial-distance term against the accumulated forecast-error term.

Worked Example: Exact Forecasts and a Nonzero Comparator

Let \(y_0=0\), \(\eta=1/2\), and take linear losses with gradients \(g_1=2\) and \(g_2=-1\). Suppose the forecasts are exact: \(m_1=2\) and \(m_2=-1\). Compare with \(u=1\).

In round 1, \(x_1=0-(1/2)(2)=-1\), and \(y_1=-1\). In round 2, \(x_2=-1-(1/2)(-1)=-1/2\), and \(y_2=-1/2\). The learner’s losses are \(2(-1)=-2\) and \((-1)(-1/2)=1/2\), for a total of \(-3/2\). The comparator’s losses are \(2(1)=2\) and \((-1)(1)=-1\), for a total of \(1\). Regret is therefore \(-3/2-1=-5/2\).

Both forecast errors are zero, so the theorem’s upper bound is \(\|1-0\|^2/(2(1/2))=1\). The computed regret \(-5/2\) is at most \(1\). Exact forecasts do not imply zero regret; the theorem is an upper bound, and regret may be negative.

Worked Example: A Convex Quadratic Loss

Consider \(\ell_t(x)=\tfrac12(x-a_t)^2\) on the real line, with \(a_1=1\), \(a_2=0\), \(y_0=0\), and \(\eta=1/2\). Use forecasts \(m_1=-1\) and \(m_2=-1/4\). Compute the actual gradients and check the regret bound against \(u=0\).

At round 1, \(x_1=0-(1/2)(-1)=1/2\). The gradient is \(g_1=x_1-a_1=-1/2\), so \(y_1=0-(1/2)(-1/2)=1/4\). The first forecast error is \(g_1-m_1=1/2\).

At round 2, \(x_2=1/4-(1/2)(-1/4)=3/8\). The gradient is \(g_2=x_2-a_2=3/8\), so \(y_2=1/4-(1/2)(3/8)=1/16\). The second forecast error is \(g_2-m_2=3/8+1/4=5/8\).

The learner’s loss is \(\tfrac12(1/2-1)^2+\tfrac12(3/8-0)^2=1/8+9/128=25/128\). The comparator \(u=0\) has loss \(\tfrac12(0-1)^2+\tfrac12(0-0)^2=1/2\). Thus regret is \(25/128-64/128=-39/128\). Since \(u=y_0=0\), the initial-distance term is zero. The error term is \((1/4)\big((1/2)^2+(5/8)^2\big)=(1/4)(41/64)=41/256\). Indeed, \(-39/128=-78/256\leq41/256\).

What the Guarantee Does—and Does Not—Say

The bound replaces a cumulative squared-gradient term with a cumulative squared forecast-error term. For example, if \(\|g_t\|\leq G\), a non-optimistic gradient method typically pays for a quantity on the scale of \(\sum_t\|g_t\|^2\). The optimistic guarantee can be substantially smaller when \(m_t\) tracks \(g_t\), even if the gradients themselves are not small. The benefit comes from predictable structure in the sequence, not from assuming that the losses are stochastic or that the forecasts are always correct.

A common mistake is to treat \(m_t\) as the gradient that has already been observed at the current round. That reasoning reverses the protocol: \(g_t\) is revealed only after \(x_t\) is chosen. The correction is to choose \(m_t\) using past information, form \(x_t=y_{t-1}-\eta m_t\), and then update \(y_t\) using the newly observed \(g_t\). Another mistake is to read the theorem as saying that regret is controlled by \(\sum_t\|g_t-m_t\|\); the proved quantity is the **sum of squared errors**, \(\sum_t\|g_t-m_t\|^2\), with the learning-rate factor shown explicitly.

Finally, this derivation is for unconstrained Euclidean actions. If actions must lie in a prescribed set, the update needs a projection or another geometry-compatible operation, and the corresponding regret proof must account for it. The unconstrained formula should not be applied to a constrained problem without that modification.

Check Your Understanding

Use the update and proof to answer the following questions.

  1. At what point in round \(t\) must \(m_t\) be available, and what information may it depend on?
  2. Write the two update equations and explain which one uses the observed gradient \(g_t\).
  3. Why does the regret bound contain \(\|g_t-m_t\|^2\) rather than only \(\|g_t\|^2\)?
  4. How does convexity convert the theorem’s linearized regret bound into a bound on loss regret?
  5. If every forecast is exact, what does the theorem’s upper bound become, and why does that not assert that regret must equal zero?
Clinical Biostats