Post · 19 min read· pp. 1504–1513

Online Optimization Post 3: Follow the Regularized Leader

The multiplicative weights algorithm is simple to define and analyze, and it has several applications, but both its definition and its analysis seem to come out of nowhere. We mentioned that all the quantities arising in the algorithm and its analysis have statistical physics interpretations, but even this observation brings up more questions than it answers. The Gibbs distribution, for example, does put more weight on lower-energy states, and so it makes sense in an optimization setting, but to get good approximations one wants to use lower temperatures, while the distributions used by the multiplicative weights algorithms have temperature 1/ϵ{1/\epsilon}, where 2ϵ{2\epsilon} is the final “amortized” regret bound, so that one uses, quite counterintuitively, higher temperatures for better approximations.

Furthermore, it is not clear how we would generalize the ideas of multiplicative weights to the case in which the set of feasible solutions K{K} is anything other than the set of distributions.

Today we discuss the “Follow the Regularized Leader” method, which provides a framework to design and analyze online algorithms in a versatile and well-motivated way. We will then see how we can “discover” the definition and analysis of multiplicative weights, and how to “discover” another online algorithm which can be seen as a generalization of projected gradient descent (that is, one can derive the projected gradient descent algorithm and its analysis from this other online algorithm).

1. Follow The Regularized Leader

We will first state some results in full generality, making no assumptions on the set K{K} of feasible solutions or on the set of loss functions ft:K→R{f_t : K \rightarrow {\mathbb R}} encountered by the algorithm at each step.

Let us try to define an online optimization algorithm from scratch. The solution xt{x_t} proposed by the algorithm at time t{t} can only depend on the previous cost functions f1,…,ft−1{f_1,\ldots,f_{t-1}}; how should it depend on it? If the offline optimal solution x{x} is consistently better than all others at each time step, then we would like xt{x_t} to be that solution, so we want xt{x_t} to be a solution that would have worked well in the previous steps. The most extreme way of implementing this idea is the Follow the Leader algorithm (abbreviated FTL), in which we set the solution at time t{t}

xt:=arg⁡min⁡x∈K∑k=1t−1fk(x)\displaystyle x_t := \arg\min_{x\in K} \sum_{k=1}^{t-1} f_k(x)

to be the best solution for the previous steps. (Note that the algorithm does not prescribe what solution to use at step t=1{t=1}.)

It is possible for FTL to perform very badly. Consider for example the “experts” setting in which we analyzed multiplicative weights: the set of feasible solutions K{K} is the set Δ{\Delta} of probability distributions over {1,…,n}{\{1,\ldots,n\}}, and the cost functions are linear ft(x)=∑iℓt(i)x(i){f_t(x) = \sum_i \ell_t(i) x(i)} with coefficients 0≤ℓt(i)≤1{0\leq \ell_t(i) \leq 1}. Suppose that n=2{n=2} and that x1=(0.5,.0.5){x_1 = (0.5,.0.5)}. Then a possible run of the algorithm could be:

  1. x1=(.5,.5){x_1 = (.5,.5)}, ℓ1=(0,.5){\ell_1 = (0,.5)}
  2. x2=(1,0){x_2 = (1,0)}, ℓ2=(1,0){\ell_2 = (1,0)}
  3. x3=(0,1){x_3 = (0,1)}, ℓ3=(0,1){\ell_3 = (0,1)}
  4. x4=(1,0){x_4 = (1,0)}, ℓ4=(1,0){\ell_4 = (1,0)}
  5. x5=(0,1){x_5 = (0,1)}, ℓ5=(0,1){\ell_5 = (0,1)}

⋮\displaystyle \vdots

In which, after T{T} steps, the algorithm suffers a loss of T−O(1){T- O(1)} while the offline optimum is T/2+O(1){T/2 + O(1)}. Thus, the regret is about T/2{T/2}, which compares very unfavorably to the O(T){O(\sqrt T)} regret of the multiplicative weight algorithm. For general n{n}, a similar example shows that the regret of FTL can be as high as about T⋅(1−1n){T\cdot \left( 1- \frac 1n \right)}.

In the above bad example, the algorithm keeps “overfitting” to the past history: if an expert is a bit better than the others, the algorithm puts all its probability mass on that expert, and the algorithm keeps changing its mind at every step. Interestingly, this is the only failure mode of the algorithm.

Theorem 1 (Analysis of FTL) For any sequence of cost functions f1,…,ft{f_1,\ldots,f_t} and any number of time steps T{T}, the FTL algorithm satisfies the regret bound

RegretT≤∑t=1Tft(xt)−ft(xt+1)\displaystyle {\rm Regret}_T \leq \sum_{t=1}^T f_t(x_t ) - f_t(x_{t+1} )

So that if the functions ft(⋅){f_t(\cdot)} are Lipschitz with respect to a distance function on K{K}, then the only way for the regret to be large is for xt{x_t} to typically be far, in that distance, from xt+1{x_{t+1}}.

Proof: Recalling the definition of regret,

RegretT:=∑t=1Tft(xt)−min⁡x∈K∑t=1Tft(x) ,\displaystyle {\rm Regret}_T := \sum_{t=1}^T f_t(x_t) - \min_{x\in K} \sum_{t=1}^T f_t(x) \ ,

the theorem is equivalent to

∑t=1Tft(xt+1)≤min⁡x∈K∑t=1Tft(x)     (1)\displaystyle \sum_{t=1}^T f_t (x_{t+1}) \leq \min_{x\in K} \sum_{t=1}^T f_t(x) \ \ \ \ \ (1)

We will prove (1) by induction. The base case T=1{T=1} is just the definition of x2{x_2}. Assuming that latex {[(1)](#ftl.analysis)}&fg=000000 is true up to T{T} we have

∑t=1T+1ft(xt+1)=(∑t=1Tft(xt+1))+fT+1(xT+2)≤∑t=1T+1ft(xT+2)=min⁡x∈K∑t=1T+1ft(x)\displaystyle \sum_{t=1}^{T+1} f_t (x_{t+1}) = \left( \sum_{t=1}^{T} f_t (x_{t+1}) \right) + f_{T+1} (x_{T+2}) \leq \sum_{t=1}^{T+1} f_t (x_{T+2}) = \min_{x\in K} \sum_{t=1}^{T+1} f_t(x)

where the middle step follows from the use of the inductive assumption, which gives

∑t=1Tft(xt+1)≤min⁡x∈K∑t=1Tft(x)≤∑t=1Tft(xT+2)\displaystyle \sum_{t=1}^{T} f_t (x_{t+1}) \leq \min_{x\in K} \sum_{t=1}^T f_t (x) \leq \sum_{t=1}^T f_t (x_{T+2})

□\Box

The above example and analysis suggest that we should modify FTL in such a way that the choices of the algorithm don’t change too much from step to step, and that the solution xt{x_t} at time t{t} should be a compromise between optimizing with respect to previous cost functions and not changing too much from step to step.

In order to do this, we introduce a new function R(⋅){R(\cdot)}, called a regularizer (more on it later), and, at each step, we compute the solution

xt:=arg⁡min⁡x∈K R(x)+∑k=1t−1fk(x)\displaystyle x_t := \arg\min_{x\in K} \ R(x) + \sum_{k=1}^{t-1} f_k(x)

This algorithm is called Follow the Regularized Leader or FTRL. Typically, the function R(⋅){R(\cdot)} is chosen to be strictly convex and to take values that are rather big in magnitude. Then x1{x_1} will be the unique minimum of R(⋅){R(\cdot)} and, at each subsequent step, xt{x_t} will be selected in a way to balance the pull toward the minimum of R(⋅){R(\cdot)} and the pull toward the FTL solution arg⁡min⁡x∈K∑kfk(x){\arg\min_{x\in K} \sum_k f_k(x)}. In particular, if R(⋅){R(\cdot)} is large in magnitude compared to each ft(⋅){f_t(\cdot)}, the solution will not change too much from step to step.

We have the following analysis that makes no assumptions on K{K}, on the cost functions ft(⋅){f_t(\cdot)} and on the regularizer (not even that the regularizer is convex).

Theorem 2 (Analysis of FTRL) For every sequence of cost functions and every regularizer function, the regret after T{T} steps of the FTRL algorithm is bounded as follows: for every x{x},

*

RegretT(x)≤(∑t=1Tft(xt)−ft(xt+1))+R(x)−R(x1)\displaystyle {\rm Regret}_T(x) \leq \left( \sum_{t=1}^T f_t(x_{t}) - f_t (x_{t+1}) \right) + R(x) - R(x_1)

where

RegretT(x):=∑t=1Tft(xt)−ft(x)\displaystyle {\rm Regret}_T (x) := \sum_{t=1}^T f_t (x_t) - f_t (x)
*

Proof: Let us run for T{T} steps the FTRL algorithm with regularizer R(⋅){R(\cdot)} and cost functions f1,…,fT{f_1,\ldots,f_T}, and call x1,…,xT{x_1,\ldots,x_T} the solutions computed by the FTL algorithm.

Now consider the following mental experiment: we run the FTL algorithm for T+1{T+1} steps, with the sequence of cost functions R,f1,…,ft{R,f_1,\ldots,f_t}, and we use x1{x_1} as a first solution. Then we see that the solutions computed by the FTL algorithm will be precisely x1,x1,x2,…,xT{x_1,x_1,x_2,\ldots,x_T}. The regret bound for FTL implies that, for every x{x},

R(x1)−R(x)+∑t=1Tft(xt)−ft(x)≤R(x1)−R(x1)+∑t=1Tft(xt)−ft(xt+1)\displaystyle R(x_1) - R(x) + \sum_{t=1}^T f_t(x_t) - f_t(x) \leq R(x_1) - R(x_1) + \sum_{t=1}^T f_t(x_t) - f_{t} (x_{t+1})

□\Box

Having established these results, the general recipe to solve an online optimization problem will be to find a regularizer function R{R} such that the minimum of R{R} “pulls away from” solutions that would make the FTL algorithm overfit, and such that there is a good balance between how big R{R} gets over K{K} (because we pay R(x∗)−R(x1){R(x^*) - R(x_1)} in the regret, where x∗{x^*} is the offline optimum) and how stable is the minimum of R(x)+∑k=1t−1fk(x){R(x) + \sum_{k=1}^{t-1} f_k(x)} as t{t} varies.

2. Negative-Entropy Regularization

Let us consider again the “experts” setting, that is, the online optimization setup in which K{K} is the set of probability distributions over {1,…,n}{\{ 1,\ldots, n\}} and the cost functions are linear ft(x)=∑iℓt(i)x(i){f_t (x) = \sum_i \ell_t (i) x(i)} with bounded coefficients.

The example we showed above showed that FTL will tend to put all the probability mass on one expert. We would like to choose a regularizer that fights this tendency by penalizing “concentrated” distributions and favoring “spread-out” distributions. This observation might trigger the thought that the entropy of a distribution is a good measure of how concentrated or spread out it is, although the entropy is actually higher for spread-out distribution and smaller for concentrated ones. So we will use as a regularizer minus the entropy, multiplied by an appropriate scaling factor:

R(x):=c⋅∑i=1nxiln⁡xi\displaystyle R(x) := c \cdot \sum_{i=1}^n x_i \ln x_i

(Entropy is usually defined using logarithms in base 2, but using natural logarithms will make it cleaner to take derivatives, and it only affects the constant factor c{c}.) With this choice of regularizer, we have

xt=arg⁡min⁡x∈Δ  (∑k=1t−1⟨ℓk,xk⟩)+c⋅∑i=1nxiln⁡xi\displaystyle x_t = \arg\min_{x\in \Delta} \ \ \left( \sum_{k=1}^{t-1} \langle \ell_k , x_k \rangle \right ) + c \cdot \sum_{i=1}^n x_i \ln x_i

To compute the minimum of the above function we will use the method of Lagrange multipliers. Specialized to our setting, the method of Lagrange multiplier states that if we want to solve the constrained minimization problem

min⁡x: aTx=b  f(x)\displaystyle \min_{x : \ a^Tx = b } \ \ f(x )

we introduce a new parameter λ{\lambda} and define the function

fλ(x):=f(x)+λ⋅(aTx−b)\displaystyle f_\lambda (x) := f(x) + \lambda \cdot (a^T x - b )

Then it is possible to prove that if x∗{x^*} is a feasible minimizer of f(⋅){f(\cdot)}, then there is at least a value of λ{\lambda} such that ∇fλ(x∗)=0{\nabla f_\lambda (x^*) = 0}, that is, such that x∗{x^*} is a stable point of fλ{f_\lambda}. So one can proceed by finding all x,λ{x,\lambda} such that ∇fλ(x)=0{\nabla f_\lambda (x) = 0} and then filtering out the values of x{x} such that aTx≠b{a^T x \neq b}, and finally looking at which of the remaining x{x} minimizes f(⋅){f(\cdot)}.

Ignoring for a moment the non-negativity constraints, the constraint x∈Δ{x\in \Delta} reduces to ∑ixi=1{\sum_i x_i = 1}, so we have to consider the function

(∑k=1t−1⟨ℓk,xk⟩)+c⋅(∑i=1nxiln⁡xi)+λ⋅(⟨x,1⟩−1)\displaystyle \left( \sum_{k=1}^{t-1} \langle \ell_k , x_k \rangle \right ) + c \cdot \left( \sum_{i=1}^n x_i \ln x_i \right) + \lambda \cdot \left( \langle x, {\bf 1} \rangle - 1\right)

The partial derivative of the above expression with respect to xi{x_i} is

(∑k=1t−1ℓk(i))+c⋅(1+ln⁡xi)+λ\displaystyle \left( \sum_{k=1}^{t-1} \ell_k (i) \right ) + c \cdot \left( 1 + \ln x_i \right) + \lambda

If we want the gradient to be zero then we want all the above expressions to be zero, which translates to

xi=exp(−1−λc−1c∑k=1t−1ℓk(i))\displaystyle x_i = {\rm exp} \left( -1 - \frac \lambda c - \frac 1c \sum_{k=1}^{t-1} \ell_k(i) \right)

There is only one value of λ{\lambda} that makes the above solution a probability distribution, and the corresponding solution is

xi=exp(−1c∑k=1t−1ℓk(i))∑jexp(−1c∑k=1t−1ℓk(j))\displaystyle x_i = \frac {{\rm exp} \left( - \frac 1c \sum_{k=1}^{t-1} \ell_k(i) \right) } {\sum_j {\rm exp} \left( - \frac 1c \sum_{k=1}^{t-1} \ell_k(j) \right) }

Notice that this is exactly the solution computed by the multiplicative weights algorithm, if we choose c=1/ϵ{c = 1/\epsilon}. So we have “rediscovered” the multiplicative weights algorithm and we have also “explained” what it does: at every step it balances the goals of finding a solution that is good for the past and that has large entropy.

Now it remains to bound, at each time step,

ft(xt)−ft(xt+1)=⟨ℓt,xt−xt+1⟩\displaystyle f_t (x_t) - f_t (x_{t+1}) = \langle \ell_t , x_t - x_{t+1} \rangle

For this, it is convenient to return to the notation that we used in describing the multiplicative weights algorithm, that is, it is convenient to work with the weights defined as

w1(i)=1\displaystyle w_1(i) = 1

wt+1(i)=wt(i)⋅eℓt(i)/c\displaystyle w_{t+1} (i) = w_t (i) \cdot e^{ \ell_t (i) / c}

so that, at each time step

xt(i)=wt(i)∑jwt(j)\displaystyle x_t(i) = \frac {w_t(i)}{\sum_j w_t (j) }

We are assuming 0≤ℓt(i)≤1{0 \leq \ell_t (i) \leq 1}, so the weights are non-increasing with time. Then

xt+1(i)=wt+1(i)∑jwt+1(j)=wt(i)e−ℓt(i)/c∑jwt+1(j)≥wt(i)e−ℓt(i)/c∑jwt(j)≥xt(i)⋅e−1/c\displaystyle x_{t+1} (i) = \frac {w_{t+1} (i) }{\sum_j w_{t+1} (j) } = \frac {w_{t} (i) e^{-\ell_t (i) /c }}{\sum_j w_{t+1} (j) } \geq \frac {w_{t} (i) e^{-\ell_t (i) /c }}{\sum_j w_{t} (j) } \geq x_t(i) \cdot e^{-1/c}

For every c≥1{c \geq 1} we have e−1/c≥1−1/c{e^{-1/c} \geq 1 - 1/c}, so

xt(i)−xt+1(i)≤1cxt(i)\displaystyle x_{t}(i) - x_{t+1}(i) \leq \frac 1c x_t (i)

and

⟨ℓt,xt−xt+1⟩≤∑iℓt(i)⋅1cxt(i)≤1c\displaystyle \langle \ell_t , x_t - x_{t+1} \rangle \leq \sum_i \ell_t(i) \cdot \frac 1c x_t(i) \leq \frac 1c

Putting it all together, we have

RegretT≤Tc+cln⁡n\displaystyle {\rm Regret}_T \leq \frac Tc + c \ln n

Choosing c=Tln⁡n{c = \sqrt{\frac T {\ln n}}}, we have

RegretT≤2Tln⁡n\displaystyle {\rm Regret}_T \leq 2 \sqrt{T \ln n}

Thus, we have reconstructed the analysis of the multiplicative weights algorithm.

Interestingly, the analysis that we derived today is not exactly identical to the one from the post on multiplicative weights. There, we derived the bound

RegretT≤ϵ∑t=1T∑i=1nℓt2(i)xt(i) +ln⁡nϵ\displaystyle {\rm Regret}_T \leq \epsilon \sum_{t=1}^T \sum_{i=1}^n \ell_t^2 (i) x_t (i) \ + \frac {\ln n}{\epsilon }

while here, setting ϵ=1/c{\epsilon = 1/c}, we derived

RegretT≤ϵ∑t=1T∑i=1nℓt(i)xt(i)+ln⁡nϵ−1ϵH(x∗)\displaystyle {\rm Regret}_T \leq \epsilon \sum_{t=1}^T \sum_{i=1}^n \ell_t (i) x_t(i) + \frac {\ln n}{\epsilon } - \frac 1 \epsilon H(x^*)

where x∗{x^*} is the offline optimum and H(x)=∑ixiln⁡1xi{H(x) = \sum_i x_i \ln \frac 1 {x_i}} is the entropy function (computed using natural logarithms).

3. L2 Regularization

Now that we have a general method, let us apply it to a new context: suppose that, as before, our cost functions are linear, but let K=Rn{K = {\mathbb R}^n}. With linear cost functions and no bound on the size of solutions, it will not be possible to talk about regret with respect to the offline optimum, because the offline optimum will always be −∞{-\infty}, but it will be possible to talk about regret with respect to a particular offline solution x{x}, which will already lead to interesting consequences.

What regularizer should we use? In reasoning about regularizers, it can be helpful to think about what would go wrong if we use FTL, and then considering what regularizer would successfully “pull away” from the bad solutions found by FTL. In this context of linear loss functions and unbounded solutions, FTL will pick an infinitely big solution at each step, or, to be more precise, the “max” in the definition of FTL is undefined. To fight this tendency of FTL to go off to infinity, it makes sense for the regularizer to be a measure of how big a solution is. Since we are going to have to compute derivatives, it is good to use a measure of “bigness” with a nice gradient, and ∣∣x∣∣2{||x ||^2} is a natural choice. So, for a scale parameter c{c} to be optimized later, our regularizer will be

R(x):=c∣∣x∣∣2\displaystyle R(x) := c || x||^2

This tells us that

x1=0\displaystyle x_ 1 = {\bf 0}

and

xt+1=arg⁡min⁡x∈Rn  c∣∣x∣∣2+∑k=1t⟨ℓk,x⟩\displaystyle x_{t+1} = \arg\min_{x \in {\mathbb R}^n} \ \ c ||x||^2 + \sum_{k=1}^t \langle \ell_k , x \rangle

The function that we are minimizing in the above expression is convex, so we just have to compute the gradient and set it to zero

2cx+∑k=1tℓk=0\displaystyle 2c x + \sum_{k=1}^t \ell_k = 0

x=−12c∑k=1tℓk\displaystyle x = - \frac 1 {2c} \sum_{k=1}^t \ell_k

Which can be also expressed as

x1=0;   xt+1=xt−12cℓt\displaystyle x_1 = {\bf 0}; \ \ \ x_{t+1} = x_t - \frac 1 {2c} \ell_t

This makes perfect sense because, in the “experts” interpretation, we want to penalize the experts that performed badly in the past. Here we have no constraints on our allocations, so we simply decrease (additively this time, not multiplicatively) the allocation to the experts that caused a higher loss.

To compute the regret bound, we have

ft(xt)−ft(xt+1)=⟨ℓt,xt−xt+1⟩=⟨ℓt,12cℓt⟩=12c∣∣ℓt∣∣2∣∣\displaystyle f_t(x_t) - f_{t} (x_{t+1}) = \langle \ell_t, x_t - x_{t+1} \rangle = \left\langle \ell_t , \frac 1 {2c} \ell_t \right\rangle = \frac 1 {2c} || \ell_t||^2 ||

and so the regret with respect to a solution x{x} is

RegretT(x)≤R(x)−R(x1)+∑t=1Tft(xt)−ft(xt+1)\displaystyle {\rm Regret}_T(x) \leq R(x) - R(x_1) + \sum_{t=1}^T f_t(x_t) - f_{t} (x_{t+1} )

=c∣∣x∣∣2+12c∑t=1T∣∣ℓt∣∣2\displaystyle = c || x||^2 + \frac 1 {2c} \sum_{t=1}^T || \ell_t||^2

If we know a bound

∀t:  ∣∣ℓt∣∣≤L\displaystyle \forall t: \ \ || \ell_t || \leq L

∣∣x∣∣≤D\displaystyle || x|| \leq D

then we can optimize c=T2D2L2{c = \sqrt{\frac T {2D^2 L^2}}} and we have

RegretT(x)≤DL2T\displaystyle {\rm Regret}_T(x) \leq D L \sqrt{ 2 T}

3.1. Dealing with Constraints

Consider now the case in which the loss functions are linear and K{K} is an arbitrary convex set. Using the same regularizer R(x)=c∣∣x∣∣2{R(x) = c || x||^2} we have the algorithm

x1=arg⁡min⁡x∈Kc∣∣x∣∣2\displaystyle x_1 = \arg\min_{x\in K} c ||x ||^2

xt+1=arg⁡min⁡x∈K  c∣∣x∣∣2+∑k=1t⟨ℓt,x⟩\displaystyle x_{t+1} = \arg\min_{x\in K} \ \ c ||x ||^2 + \sum_{k=1}^{t} \langle \ell_t , x \rangle

How can we solve the above constrained optimization problem? A very helpful observation is that we can first solve the unconstrained optimization and then project on K{K}, that is we can proceed as follows:

yt+1=arg⁡min⁡y∈Rn  c∣∣y∣∣2+∑k=1t⟨ℓt,y⟩\displaystyle y_{t+1} = \arg\min_{y\in {\mathbb R}^n} \ \ c ||y ||^2 + \sum_{k=1}^{t} \langle \ell_t , y \rangle

xt+1′=ΠK(yt+1)=arg⁡min⁡x∈K∣∣x−yt+1∣∣\displaystyle x'_{t+1} = \Pi_K (y_{t+1} ) = \arg\min_{x\in K} || x - y_{t+1} ||

and we claim that we always have xt+1′=xt+1{x'_{t+1} = x_{t+1}}. The fact that we can reduce a regularized constrained optimization problem to an unconstrained problem and a projection is part of a broader theory that we will describe in a later post. For now, we will limit to prove the equivalence in this specific setting. First of all, we already have an expression for yt+1{y_{t+1}}, namely

yt+1=−12c∑k=1tℓt\displaystyle y_{t+1} = - \frac 1{2c} \sum_{k=1}^t \ell_t

Now the definition of xt+1′{x'_{t+1}} is

xt+1′=arg⁡min⁡x∈K∣∣x−yt+1∣∣\displaystyle x'_{t+1} = \arg\min_{x\in K} || x - y_{t+1} ||

=arg⁡min⁡x∈K∣∣x−yt+1∣∣2\displaystyle = \arg\min_{x\in K} || x - y_{t+1} ||^2

=arg⁡min⁡x∈K∣∣x∣∣2−2⟨x,yt+1⟩+∣∣yt+1∣∣2\displaystyle = \arg\min_{x\in K} ||x||^2 - 2 \left \langle x , y_{t+1} \right\rangle + || y_{t+1} ||^2

=arg⁡min⁡x∈K∣∣x∣∣2−2⟨x,yt+1⟩\displaystyle = \arg\min_{x\in K} ||x||^2 - 2 \left \langle x , y_{t+1} \right\rangle

=arg⁡min⁡x∈K∣∣x∣∣2−2⟨x,12c∑k=1tℓt⟩\displaystyle = \arg\min_{x\in K} ||x||^2 - 2 \left\langle x , \frac 1{2c} \sum_{k=1}^t \ell_t \right\rangle

=arg⁡min⁡x∈Kc∣∣x∣∣2−∑k=1t⟨x,ℓt⟩=xt+1\displaystyle = \arg\min_{x\in K} c ||x||^2 - \sum_{k=1}^t \left\langle x , \ell_t \right\rangle = x_{t+1}

In order to bound the regret, we have to compute

ft(xt)−ft(xt+1)=⟨ℓt,xt−xt+1⟩≤∣∣ℓt∣∣⋅∣∣xt−xt+1∣∣\displaystyle f_t(x_t) - f_t(x_{t+1} ) = \langle \ell_t , x_t - x_{t+1} \rangle \leq || \ell_t || \cdot ||x_t - x_{t+1} ||

and since L2 projections cannot increase L2 distances, we have

∣∣xt−xt+1∣∣≤∣∣yt−yt+1∣∣=12c∣∣ℓt∣∣\displaystyle || x_t - x_{t+1} || \leq || y_t - y_{t+1} || = \frac 1 {2c} || \ell_t ||

So the regret bound is

RegretT≤c∣∣x∗∣∣2−c∣∣x1∣∣2+12c∑t=1T∣∣ℓt∣∣2\displaystyle {\rm Regret}_T \leq c ||x^*||^2 - c|| x_1||^2 + \frac 1 {2c} \sum_{t=1}^T || \ell_t ||^2

If D{D} is an upper bound to max⁡x∈K∣∣x∣∣{\max_{x\in K} || x||}, and L{L} is an upper bound to the norm ∣∣ℓt∣∣{|| \ell_t ||} of all the loss vectors, then

RegretT≤cD2+12cTL2\displaystyle {\rm Regret}_T \leq c D^2 + \frac 1 {2c} T L^2

which can be optimized to

RegretT≤DL2T\displaystyle {\rm Regret}_T \leq DL \sqrt {2T}

3.2. Deriving the Analysis of Gradient Descent

Suppose that g:K→R{g: K \rightarrow {\mathbb R}} is a convex function whose gradient ∇g{\nabla g} is well defined at all points in K{K}, and that we are interested in minimizing g{g}. Then a way to reduce this problem to online optimization would be to use the function g{g} as loss function at each step. Then the offline optimum would be the minimizer of g{g}, and achieving small regret means that 1T∑tg(xt){\frac 1T \sum_t g(x_t)} is close to the minimum of g{g}, and so the best xt{x_t} is an approximate minimizer.

Unfortunately, this is not a very helpful idea, because if we ran an FTRL algorithm against an adversary that keeps proposing g{g} as a cost function at each step then we would have

xt+1=arg⁡min⁡x∈KR(x)+t⋅g(x)\displaystyle x_{t+1} = \arg\min_{x\in K} R(x) + t \cdot g(x)

which, for large t{t}, is essentially the same problem as minimizing g{g}, so we have basically reduced the problem of minimizing g{g} to itself.

Indeed, the power of the FTRL algorithm is that the algorithm does well even though it does not know the cost function, and if we keep using the same cost function at each step we are not making a good use of its power. Now, suppose that we use cost functions ft{f_t} such that

  • ft(xt)=g(xt){f_t(x_t) = g(x_t)}
  • ∀x∈K  ft(x)≤g(x){\forall x\in K \ \ f_t(x) \leq g(x)}

Then, after T{T} steps, we have

∑t=1Tg(xt)=∑t=1Tft(xt)=RegretT+min⁡x∈K∑t=1Tft(x)≤RegretT+min⁡x∈K∑t=1Tg(x)\displaystyle \sum_{t=1}^T g(x_t) = \sum_{t=1}^T f_t(x_t) = {\rm Regret}_T + \min{x\in K} \sum_{t=1}^T f_t(x) \leq {\rm Regret}_T + \min_{x\in K} \sum_{t=1}^T g (x)

meaning

1T∑t=1Tg(xt)≤RegretTT+min⁡x∈Kg(x)\displaystyle \frac 1T \sum_{t=1}^T g(x_t) \leq \frac {{\rm Regret}_T}T + \min_{x\in K} g(x)

and so one of the xt{x_t} is an approximate minimizer. Indeed, using convexity, we also have

g(1T∑t=1Txt)≤1T∑t=1Tg(xt)≤RegretTT+min⁡x∈Kg(x)\displaystyle g \left( \frac 1T \sum_{t=1}^T x_t \right) \leq \frac 1T \sum_{t=1}^T g(x_t) \leq \frac {{\rm Regret}_T}T + \min_{x\in K} g(x)

and so the average of the xt{x_t} is also an approximate minimizer. From the point of view of exploiting FTRL do to minimize g{g}, cost functions ft{f_t} as above work just as well as presenting g{g} as a cost functions at each step.

How do we find cost functions that satisfy the above two properties and for which the FTRL algorithm is easy to implement? The idea is to let ft{f_t} be the linear approximation of g{g} at xt{x_t}:

ft(x):=g(xt)+⟨∇g(xt),x−xt⟩\displaystyle f_t (x) := g(x_t) + \langle \nabla g (x_t), x - x_t \rangle

The ft(xt)=g(xt){f_t(x_t) = g(x_t)} condition is immediate, and

g(x)≥ft(x)\displaystyle g(x) \geq f_t (x)

is a consequence of the convexity of g{g}.

The cost functions that we have defined are affine functions, that is, each of them equals a constant plus a linear function

ft(x)=(g(xt)−⟨∇g(xt),xt⟩)+⟨∇g(xt),x⟩\displaystyle f_t(x) = \left( g(x_t) - \langle \nabla g(x_t) , x_t\rangle \right) + \langle \nabla g(x_t) , x \rangle

Adding a constant term to a cost function does not change the iteration of FTRL, and does not change the regret (because the same term is added both to the solution found by the algorithm and to the offline optimum), so the algorithm is just initialized with

y1=0\displaystyle y_1 = {\bf 0}

x1=ΠK(0)=arg⁡min⁡x∈K∣∣x∣∣\displaystyle x_1 = \Pi_K({\bf 0}) = \arg\min_{x\in K} || x||

and then continues with the update rules

yt+1=yt−12c∇g(xt)\mboxfort≥1\displaystyle y_{t+1} =y_t -\frac 1 {2c} \nabla g (x_t) \mbox{ for } t \geq 1

xt+1=ΠK(yt+1)=arg⁡min⁡x∈K∣∣x−yt+1∣∣\mboxfort≥1\displaystyle x_{t+1} = \Pi_K(y_{t+1}) = \arg\min_{x\in K} || x - y_{t+1} || \mbox{ for } t \geq 1

which is just projected gradient descent.

If we have known upper bounds

∀x∈K  ∣∣∇g(x)∣∣≤L\displaystyle \forall x \in K \ \ || \nabla g(x) || \leq L

and

∀x∈K  ∣∣x∣∣≤D\displaystyle \forall x \in K \ \ || x || \leq D

then we have

g(1T∑t=1Txt)≤DL⋅2T+min⁡x∈K∑t=1Tg(x)\displaystyle g \left( \frac 1 T \sum_{t=1}^T x_t \right ) \leq DL \cdot \sqrt{\frac 2 T} + \min_{x\in K} \sum_{t=1}^T g (x)

which means that to achieve additive error ϵ{\epsilon} it is enough to proceed for 2D2L2/ϵ2{2D^2L^2 / \epsilon^2} steps.