Making Gradient Descent Optimal for Strongly Convex Stochastic Optimization
Alexander Rakhlin, Ohad Shamir, Karthik Sridharan
Introduction
Stochastic gradient descent (SGD) is one of the simplest and most popular first-order methods to solve convex learning problems. Given a convex loss function and a training set of examples, SGD can be used to obtain a sequence of predictors, whose average has a generalization error which converges (with ) to the optimal one in the class of predictors we consider. The common framework to analyze such first-order algorithms is via stochastic optimization, where our goal is to optimize an unknown convex function , given only unbiased estimates of ’s subgradients (see Sec. 2 for a more precise definition).
An important special case is when is strongly convex (intuitively, can be lower bounded by a quadratic function). Such functions arise, for instance, in Support Vector Machines and other regularized learning algorithms. For such problems, there is a well-known convergence guarantee for SGD with averaging. This rate is obtained using the analysis of the algorithm in the harder setting of online learning Hazan et al. 2007, combined with an online-to-batch conversion (see Hazan & Kale 2011 for more details).
Surprisingly, a recent paper by Hazan and Kale Hazan & Kale 2011 showed that in fact, an is not the best that one can achieve for strongly convex stochastic problems. In particular, an optimal rate can be obtained using a different algorithm, which is somewhat similar to SGD but is more complex (although with comparable computational complexity) Roughly speaking, the algorithm divides the iterations into exponentially increasing epochs, and runs stochastic gradient descent with averaging on each one. The resulting point of each epoch is used as the starting point of the next epoch. The algorithm returns the resulting point of the last epoch.. A very similar algorithm was also presented recently by Juditsky and Nesterov Juditsky & Nesterov 2010.
These results left an important gap: Namely, whether the true convergence rate of SGD, possibly with some sort of averaging, might also be , and the known result is just an artifact of the analysis. Indeed, the whole motivation of Hazan & Kale 2011 was that the standard online analysis is too loose to analyze the stochastic setting properly. Perhaps a similar looseness applies to the analysis of SGD as well? This question has immediate practical relevance: if the new algorithms enjoy a better rate than SGD, it might indicate they will work better in practice, and that practitioners should abandon SGD in favor of them.
In this paper, we study the convergence rate of SGD for stochastic strongly convex problems, with the following contributions:
First, we extend known results to show that if is not only strongly convex, but also smooth (with respect to the optimum), then SGD with and without averaging achieves the optimal convergence rate.
We then show that for non-smooth , there are cases where the convergence rate of SGD with averaging is . In other words, the bound for general strongly convex problems is real, and not just an artifact of the currently-known analysis.
However, we show that one can recover the optimal convergence rate by a simple modification of the averaging step: Instead of averaging of points, we only average the last points, where is arbitrary. Thus, to obtain an optimal rate, one does not need to use an algorithm significantly different than SGD, such as those discussed earlier.
We perform an empirical study on both artificial and real-world data, which supports our findings.
Following the paradigm of Hazan & Kale 2011, we analyze the algorithm directly in the stochastic setting, and avoid an online analysis with an online-to-batch conversion. Our rate upper bounds are shown to hold in expectation, but we also sketch how we can obtain high-probability bounds (up to a factor). While the focus here is on getting the optimal rate in terms of , we note that our upper bounds are also optimal in terms of other standard problem parameters, such as the strong convexity parameter and the variance of the stochastic gradients.
In terms of related work, we note that the performance of SGD in a stochastic setting has been extensively researched in stochastic approximation theory (see for instance Kushner & Yin 2003). However, these results are usually obtained under smoothness assumptions, and are often asymptotic, so we do not get an explicit bound in terms of which applies to our setting. We also note that a finite-sample analysis of SGD in the stochastic setting was recently presented in Bach & Moulines 2011. However, the focus there was different than ours, and also obtained bounds which hold only in expectation rather than in high probability. More importantly, the analysis was carried out under stronger smoothness assumptions than our analysis, and to the best of our understanding, does not apply to general, possibly non-smooth, strongly convex stochastic optimization problems. For example, smoothness assumptions may not cover the application of SGD to support vector machines (as in Shalev-Shwartz et al. 2011), since it uses a non-smooth loss function, and thus the underlying function we are trying to stochastically optimize may not be smooth.
Preliminaries
We use bold-face letters to denote vectors. Given some vector , we use to denote its -th coordinate. Similarly, given some indexed vector , we let denote its -th coordinate. We let denote the indicator function for some event .
We will focus on an important special case of the problem, characterized by being a strongly convex function. Formally, we say that a function is -strongly convex, if for all and any subgradient of at ,
Another possible property of we will consider is smoothness, at least with respect to the optimum . Formally, a function is -smooth with respect to if for all ,
Such functions arise, for instance, in logistic and least-squares regression, and in general for learning linear predictors where the loss function has a Lipschitz-continuous gradient.
The algorithm we focus on is stochastic gradient descent (SGD). The SGD algorithm is parameterized by step sizes , and is defined as follows (below, we assume for simplicity that the algorithm is initialized at , following common practice).
Let , where is the projection operator on .
This algorithm returns a sequence of points . To obtain a single point, one can use several strategies. Perhaps the simplest one is to return the last point, . Another procedure, for which the standard online analysis of SGD applies Hazan et al. 2007, is to return the average point
In terms of the step size, we note that the appropriate regime to consider is (see Appendix A for a fuller discussion of this). In particular, we will assume for the sake of our upper bounds that . This assumption simplifies the analysis substantially, while not losing much in terms of generality. To see why, suppose the step sizes are actually for some If the step size is too small and is much smaller than , the SGD analysis is known to fail (Nemirovski et al. 2009). , and let . Then this step size is equivalent to . Since any -strongly convex function is also -strongly convex (as ), then we can just analyze the algorithm’s behavior as if we run it on a -strongly convex function, using the default step size . If so desired, one can then substitute instead of in the final bound, to see the upper bound in terms of and .
Full proofs of our results are provided in Appendix B.
Smooth Functions
We begin by considering the case where the expected function is both strongly convex and smooth with respect to . Our starting point is to show a for the last point obtained by SGD. This result is well known in the literature (see for instance Nemirovski et al. 2009) and we include a proof for completeness. Later on, we will show how to extend it to a high-probability bound.
The theorem is an immediate corollary of the following key lemma, and the definition of -smoothness with respect to .
We now turn to discuss the behavior of the average point , and show that for smooth , it also enjoys an optimal convergence rate.
A rough proof intuition is the following: Lemma 1 implies that the Euclidean distance of from is on the order of , so the squared distance of from is on the order of , and the rest follows from smoothness.
Non-Smooth Functions
We now turn to the discuss the more general case where the function may not be smooth (i.e. there is no constant which satisfies Eq. (2) uniformly for all ). In the context of learning, this may happen when we try to learn a predictor with respect to a non-smooth loss function, such as the hinge loss.
As discussed earlier, SGD with averaging is known to have a rate of at most . In the previous section, we saw that for smooth , the rate is actually . Moreover, Hazan & Kale 2011 showed that for using a different algorithm than SGD, one can obtain a rate of even in the non-smooth case. This might lead us to believe that an rate for SGD is possible in the non-smooth case, and that the analysis is simply not tight.
However, this intuition turns out to be wrong. Below, we show that there are strongly convex stochastic optimization problems in Euclidean space, in which the convergence rate of SGD with averaging is lower bounded by . Thus, the logarithm in the bound is not merely a shortcoming in the standard online analysis of SGD, but is really a property of the algorithm.
We begin with the following relatively simple example, which shows the essence of the idea. Let be the -strongly convex function
The following theorem implies in this case, the convergence rate of SGD with averaging has a lower bound. The intuition for this is that the global optimum lies at a corner of , so SGD “approaches” it only from one direction. As a result, averaging the points returned by SGD actually hurts us.
Consider the strongly convex stochastic optimization problem presented above. If SGD is initialized at any point in , and ran with , then for any , where , we have
When is considered a constant, this lower bound is .
While the lower bound scales with , we remind the reader that one must pick with constant for an optimal convergence rate in general (see discussion in Sec. 2).
This example is relatively straightforward but not fully satisfying, since it crucially relies on the fact that is on the border of . In strongly convex problems, usually lies in the interior of , so perhaps the lower bound does not hold in such cases. Our main result, presented below, shows that this is not the case, and that even if is well inside the interior of , an rate for SGD with averaging can be unavoidable. The intuition is that we construct a non-smooth , which forces to approach the optimum from just one direction, creating the same effect as in the previous example.
In particular, let be the -strongly convex function
over the domain , which has a global minimum at . Suppose the stochastic gradient oracle, given a point , returns the gradient estimate
Consider the strongly convex stochastic optimization problem presented above. If SGD is initialized at any point with , and ran with , then for any , where , we have
When is considered a constant, this lower bound is .
We note that the requirement of is just for convenience, and the analysis also carries through, with some second-order factors, if we let .
Recovering an 𝒪(1/T)\mathcal{O}(1/T) Rate for SGD with α\alpha-Suffix Averaging
In the previous section, we showed that SGD with averaging may have a rate of for non-smooth . To get the optimal rate for any , we might turn to the algorithms of Hazan & Kale 2011 and Juditsky & Nesterov 2010. However, these algorithms constitute a significant departure from standard SGD. In this section, we show that it is actually possible to get an rate using a much simpler modification of the algorithm: given the sequence of points provided by SGD, instead of returning the average , we average and return just a suffix, namely
for some constant (assuming and are integers). We call this procedure -suffix averaging.
Note that for any constant , the bound above is . This matches the optimal guarantees in Hazan & Kale 2011 up to constant factors. However, this is shown for standard SGD, as opposed to the more specialized algorithm of Hazan & Kale 2011. Also, it is interesting to note that this bound is comparable to the bound of Thm. 1 for the last iterate, when is also smooth, as long as . However, Thm. 1 degrades as the function becomes less smooth. In contrast, Thm. 5 implies that with an averaging scheme, we get an optimal rate even if the function is not smooth. Finally, we note that it might be tempting to use Thm. 5 as a guide to choose the averaging window, by optimizing the bound for (which turns out to be ). However, we note that the optimal value of is dependent on the constants in the bound, which may not be the tightest or most “correct” ones.
The proof combines the analysis of online gradient descent Hazan et al. 2007 and Lemma 1. In particular, starting as in the proof of Lemma 1, and extracting the inner products, we get
One potential disadvantage of suffix averaging is that if we cannot store all the iterates in memory, then we need to know from which iterate to start computing the suffix average (in contrast, standard averaging can be computed “on-the-fly” without knowing the stopping time in advance). However, even if is not known, this can be addressed in several ways. For example, since our results are robust to the value of , it is really enough to guess when we passed some “constant” portion of all iterates. Alternatively, one can divide the rounds into exponentially increasing epochs, and maintain the average just of the current epoch. Such an average would always correspond to a constant-portion suffix of all iterates.
High-Probability Bounds
Let and assume . Suppose is -strongly convex over a convex set , and that with probability . Then if we pick , it holds with probability at least that for any ,
To obtain high probability versions of Thm. 1, Thm. 2, and Thm. 5, one needs to use this lemma in lieu of Lemma 1 in their proofs. This leads overall to rates of the form which hold with probability .
Experiments
We now turn to empirically study how the algorithms behave, and compare it to our theoretical findings.
We studied the following four algorithms:
Sgd-A: Performing SGD and then returning the average point over all rounds.
Sgd-: Performing SGD with -suffix averaging. We chose - namely, we return the average point over the last rounds.
Sgd-L: Performing SGD and returning the point obtained in the last round.
Epoch-Gd: The optimal algorithm of Hazan & Kale 2011 for strongly convex stochastic optimization.
First, as a simple sanity check, we measured the performance of these algorithms on a simple, strongly convex stochastic optimization problem, which is also smooth. We define , and . The stochastic gradient oracle, given a point , returns the stochastic gradient where is uniformly distributed in . Clearly, this is an unbiased estimate of the gradient of at . The initial point of all 4 algorithms was chosen uniformly at random from . The results are presented in Fig. 1, and it is clear that all 4 algorithms indeed achieve a rate, matching our theoretical analysis (Thm. 1, Thm. 2 and Thm. 5). The results also seem to indicate that Sgd-A has a somewhat worse performance in terms of leading constants.
Second, as another simple experiment, we measured the performance of the algorithms on the non-smooth, strongly convex problem described in the proof of Thm. 4. In particular, we simulated this problem with , and picked uniformly at random from . The results are presented in Fig. 2. As our theory indicates, Sgd-A seems to have an convergence rate, whereas the other 3 algorithms all seem to have the optimal convergence rate. Among these algorithms, the SGD variants Sgd-L and Sgd- seem to perform somewhat better than Epoch-Gd. Also, while the average performance of Sgd-L and Sgd- are similar, Sgd- has less variance. This is reasonable, considering the fact that Sgd- returns an average of many points, whereas Sgd-L return only the very last point.
Finally, we performed a set of experiments on real-world data. We used the same 3 binary classification datasets (ccat,cov1 and astro-ph) used by Shalev-Shwartz et al. 2011 and Joachims 2006, to test the performance of optimization algorithms for Support Vector Machines using linear kernels. Each of these datasets is composed of a training set and a test set. Given a training set of instance-label pairs, , we defined to be the standard (non-smooth) objective function of Support Vector Machines, namely
Following Shalev-Shwartz et al. 2011 and Joachims 2006, we took for ccat, for cov1, and for astro-ph. The stochastic gradient given was computed by taking a single randomly drawn training example , and computing the gradient with respect to that example, namely
The results of the experiments are presented in Fig. 3,Fig. 4 and Fig. 5. In all experiments, Sgd-A performed the worst. The other 3 algorithms performed rather similarly, with Sgd- being slightly better on the Cov1 dataset, and Sgd-L being slightly better on the other 2 datasets.
In summary, our experiments indicate the following:
Sgd-A, which averages over all predictors, is worse than the other approaches. This accords with our theory, as well as the results reported in Shalev-Shwartz et al. 2011.
The Epoch-Gd algorithm does have better performance than Sgd-A, but a similar or better performance was obtained using the simpler approaches of -suffix averaging (Sgd-) or even just returning the last predictor (Sgd-L). The good performance of Sgd- is supported by our theoretical results, and so does the performance of Sgd-L in the strongly convex and smooth case.
Sgd-L also performed rather well (with what seems like a rate) on the non-smooth problem reported in Fig. 2, although with a larger variance than Sgd-. Our current theory does not cover the convergence of the last predictor in non-smooth problems - see the discussion below.
Discussion
In this paper, we analyzed the behavior of SGD for strongly convex stochastic optimization problems. We demonstrated that this simple and well-known algorithm performs optimally whenever the underlying function is smooth, but the standard averaging step can make it suboptimal for non-smooth problems. However, a simple modification of the averaging step suffices to recover the optimal rate, and a more sophisticated algorithm is not necessary. Our experiments seem to support this conclusion.
There are several open issues remaining. In particular, the rate in the non-smooth case still requires some sort of averaging. However, in our experiments and other studies (e.g. Shalev-Shwartz et al. 2011), returning the last iterate also seems to perform quite well. Our current theory does not cover this - at best, one can use Lemma 1 and Jensen’s inequality to argue that the last iterate has a rate, but the behavior in practice is clearly much better. Does SGD, without averaging, obtain an rate for general strongly convex problems? Also, a fuller empirical study is warranted of whether and which averaging scheme is best in practice.
Acknowledgements: We thank Elad Hazan and Satyen Kale for helpful comments, and to Simon Lacoste-Julien for pointing out a bug in Lemma 1 in a previous version of this paper.
References
Appendix A Justifying ηt=Θ(1/t)\eta_{t}=\Theta(1/t) Step-Sizes
In this appendix, we justify our focus on the step-size regime , by showing that for other step sizes, one cannot hope for an optimal convergence rate in general.
Let us begin by considering the scalar, strongly convex function , in the deterministic case where with probability , and show that cannot be smaller than . Intuitively, such small step sizes do not allow the iterates to move towards the optimum sufficiently fast. More formally, starting from (say) and using the recursive equality , we immediately get . Thus, if we want to obtain a convergence rate using the iterates returned by the algorithm, we must at least require that
For large enough and small enough , , and we get that must scale at least logarithmically with . This requires .
Appendix B Proofs
In this subsection we collect some technical Results we will need for the other proofs.
Intuitively, the lemma holds because the strong convexity of implies that the expected value of must strictly increase as we get farther from . More precisely, strong convexity implies that for any ,
Combining this and Eq. (5), we get that for all ,
The following version of Freedman’s inequality appears in De La Peña 1999 (Theorem 1.2A):
Let be a martingale difference sequence with a uniform upper bound on the steps . Let denote the sum of conditional variances,
The proof of the following lemma is taken almost verbatim from Bartlett et al. 2008, with the only modification being the use of Theorem 6 to avoid an unnecessary union bound.
Let be a martingale difference sequence with a uniform bound for all . Let be the sum of conditional variances of ’s. Further, let . Then we have, for any and ,
Note that a crude upper bound on is . Thus, . We choose a discretization such that for and . We will specify the choice of shortly. We then have,
where the last inequality follows from Theorem 6. If we now choose , then for all . Hence every term in the above summation is bounded by . Choosing ensures that . Thus we have
B.2 Proof of Lemma 1
By the strong convexity of and the fact that minimizes in , we have
Also, by convexity of , for any point and any we have . Using these inequalities, we have the following:
Plugging in , we get
B.3 Proof of Thm. 2
For any , define . Then we have
By an induction argument (using Lemma 2 for the base case), it is easy to verify that
By the assumed smoothness of with respect to , we have . Combining it with the inequality above, the result follows.
B.4 Proof of Thm. 3
The SGD iterate can be written separately for the first coordinate as
Fix some , and suppose first that . Conditioned on this event, we have
since implies . On the other hand, if , we are still guaranteed that by the domain constraints. Using these results, we get
Substituting gives the required result.
B.5 Proof of Thm. 4
The SGD iterate for the first coordinate is
The intuition of the proof is that whenever becomes negative, then the large gradient of causes to always be significantly larger than . This means that in some sense, is “constrained” to be larger than , mimicking the actual constraint in the example of Thm. 3 and forcing the same kind of behavior, with a resulting rate.
To make this intuition rigorous, we begin with the following lemma, which shows that can never be significantly smaller than , or “stay” below for more than one iteration.
For any , it holds that
Suppose first that . Then by Eq. (9) and the fact that , we get . Moreover, in that case, if , then by Eq. (9) and the previous observation,
Since , we have , which implies that the above is lower bounded by
Moreover, since , we have , so the projection operator is unnecessary, and we get overall that
This result was shown to hold assuming that . If , then repeating the argument above for instead of , we must have , so the statement in the lemma holds also when . ∎
We turn to the proof of Thm. 4 itself. By Lemma 4, if , then implies , and moreover, . Therefore, we have the following, where the sums below are only over ’s which are between and :
Now, we claim that the probabilities above can be lower bounded by a constant. To see this, consider each such probability for , conditioned on the event . Using the fact that , we have
This probability is at most , since it asks for being constrained in an interval of size , whereas is uniformly distributed over $4$. As a result, we get
From this, we can lower bound Eq. (10) as follows:
Now, by Lemma 4, for any realization of , the indicators cannot equal consecutively. Therefore, must always be at least . Plugging it in the equation above, we get the lower bound . Summing up, we have shown that
By the boundedness assumption on , we have To analyze the case where is unbounded, one can replace this by a coarse bound on how much can change in the first iterations, since the step sizes are bounded and is essentially a constant anyway. , so
B.6 Proof of Thm. 5
Extracting the inner product and summing over , we get
In particular, since we take , we get
It can be shown that . Plugging it in and slightly simplifying, we get the desired bound. ∎
B.7 Proof of Proposition 1
To prove this proposition, we will first prove the two auxiliary results, which rewrite in a more explicit form and provide a loose uniform upper bound. We will use the notation to denote .
For all , it holds with probability that
The proof is analogous to that of Lemma 2, using the stronger condition that (which follows from the assumption with probability ). Using strong convexity, we have
The lemma trivially holds for . Otherwise, divide both sides by , and the result follows. ∎
Under the conditions of Proposition 1, it holds for any that
By the strong convexity of and the fact that minimizes in , we have
Also, by convexity of , for any point and any we have . Using these inequalities, we have the following:
Unwinding this recursive inequality till , we get that for any ,
Plugging this back, we get the desired bound. ∎
Considering the sum , we have that the sum of conditional variances satisfies
where the last upper bound is by Lemma 5.
We now apply Lemma 3 to the sum of martingale differences , and get that as long as and , then with probability at least , for all ,
Plugging this back into Eq. (12), we get that with probability at least , for all ,
What is left to do now is an induction argument, to show that for a suitably chosen value of . By Lemma 5, this certainly holds for if . To show the induction step, let us rewrite the displayed inequality above as
where and . By the induction hypothesis, for all . Therefore, to show that , it suffices to find a sufficiently large value of so that
Multiplying both sides by , switching sides, and using the fact that as well as is at most for any , it follows that should satisfy
Solving the quadratic inequality, we get that should satisfy
Taking the square of both sides and using the fact that , it is again sufficient that
Substituting in the values of , we get
the induction hypothesis holds. Also, recall that for the base case to hold, we also need to assume , but this automatically holds for the value of above (since we assume ). This gives us the required result.