Stochastic Dual Coordinate Ascent Methods for Regularized Loss Minimization
Shai Shalev-Shwartz, Tong Zhang
Introduction
For example, given labels in , the SVM problem (with linear kernels and no bias term) is obtained by setting . Regularized logistic regression is obtained by setting . Regression problems also fall into the above. For example, ridge regression is obtained by setting , regression with the absolute-value is obtained by setting , and support vector regression is obtained by setting , for some predefined insensitivity parameter .
Let be the optimum of (1). We say that a solution is -sub-optimal if . We analyze the runtime of optimization procedures as a function of the time required to find an -sub-optimal solution.
The dual objective in (2) has a different dual variable associated with each example in the training set. At each iteration of DCA, the dual objective is optimized with respect to a single dual variable, while the rest of the dual variables are kept in tact.
then it is known that , where is an optimal solution of (2). It is also known that which immediately implies that for all and , we have , and hence the duality gap defined as
can be regarded as an upper bound of the primal sub-optimality .
We focus on a stochastic version of DCA, abbreviated by SDCA, in which at each round we choose which dual coordinate to optimize uniformly at random. The purpose of this paper is to develop theoretical understanding of the convergence of the duality gap for SDCA.
We analyze SDCA either for -Lipschitz loss functions or for -smooth loss functions, which are defined as follows. Throughout the paper, we will use to denote a sub-gradient of a convex function , and use to denote its sub-differential.
where is the derivative of .
Our main findings are: in order to achieve a duality gap of ,
For loss functions which are almost everywhere smooth (such as the hinge-loss), we can obtain rate better than the above rate for Lipschitz loss. See Section 5 for a precise statement.
Related Work
DCA methods are related to decomposition methods . While several experiments have shown that decomposition methods are inferior to SGD for large scale SVM , recently argued that SDCA outperform the SGD approach in some regimes. For example, this occurs when we need relatively high solution accuracy so that either SGD or SDCA has to be run for more than a few passes over the data.
However, our theoretical understanding of SDCA is not satisfying. Several authors (e.g. ) proved a linear convergence rate for solving SVM with DCA (not necessarily stochastic). The basic technique is to adapt the linear convergence of coordinate ascent that was established by . The linear convergence means that it achieves a rate of after passes over the data, where . This convergence result tells us that after an unspecified number of iterations, the algorithm converges faster to the optimal solution than SGD.
However, there are two problems with this analysis. First, the linear convergence parameter, , may be very close to zero and the initial unspecified number of iterations might be very large. In fact, while the result of does not explicitly specify , an examine of their proof shows that is proportional to the smallest nonzero eigenvalue of , where is the data matrix with its -th row be the -th data point . For example if two data points becomes closer and closer, then . This dependency is problematic in the data laden domain, and we note that such a dependency does not occur in the analysis of SGD.
Some analyses of stochastic coordinate ascent provide solutions to the first problem mentioned above. For example, analyzed an exponentiated gradient dual coordinate ascent algorithm. The algorithm analyzed there (exponentiated gradient) is different from the standard DCA algorithm which we consider here, and the proof techniques are quite different. Consequently their results are not directly comparable to results we obtain in this paper. Nevertheless we note that for SVM, their analysis shows a convergence rate of in order to achieve -sub-optimality (on the dual) while our analysis shows a convergence of to achieve duality gap; for logistic regression, their analysis shows a convergence rate of in order to achieve -sub-optimality on the dual while our analysis shows a convergence of to achieve duality gap.
In addition, , and later have analyzed randomized versions of coordinate descent for unconstrained and constrained minimization of smooth convex functions. [3, Theorem 4] applied these results to the dual SVM formulation. However, the resulting convergence rate is which is, as mentioned before, inferior to the results we obtain here. Furthermore, neither of these analyses can be applied to logistic regression due to their reliance on the smoothness of the dual objective function which is not satisfied for the dual formulation of logistic regression. We shall also point out again that all of these bounds are for the dual sub-optimality, while as mentioned before, we are interested in the primal sub-optimality.
In this paper we derive new bounds on the duality gap (hence, they also imply bounds on the primal sub-optimality) of SDCA. These bounds are superior to earlier results, and our analysis only holds for randomized (stochastic) dual coordinate ascent. As we will see from our experiments, randomization is important in practice. In fact, the practical convergence behavior of (non-stochastic) cyclic dual coordinate ascent (even with a random ordering of the data) can be slower than our theoretical bounds for SDCA, and thus cyclic DCA is inferior to SDCA. In this regard, we note that some of the earlier analysis such as can be applied both to stochastic and to cyclic dual coordinate ascent methods with similar results. This means that their analysis, which can be no better than the behavior of cyclic dual coordinate ascent, is inferior to our analysis.
Recently, derived a stochastic coordinate ascent for structural SVM based on the Frank-Wolfe algorithm. Specifying one variant of their algorithm to binary classification with the hinge loss, yields the SDCA algorithm for the hinge-loss. The rate of convergence derived for their algorithm is the same as the rate we derive for SDCA with a Lipschitz loss function.
The following table summarizes our results in comparison to previous analyses. Note that for SDCA with Lipschitz loss, we observe a faster practical convergence rate, which is explained with our refined analysis in Section 5.
Basic Results
The generic algorithm we analyze is described below. In the pseudo-code, the parameter indicates the number of iterations while the parameter can be chosen to be a number between to . Based on our analysis, a good choice of is to be . In practice, however, the parameters and are not required as one can evaluate the duality gap and terminate when it is sufficiently small.
Procedure SDCA Let Iterate: for : Randomly pick Find to maximize . Output (Averaging option): Let Let return Output (Random option): Let and for some random return
We analyze the algorithm based on different assumptions on the loss functions. To simplify the statements of our theorems, we always assume the following:
If we choose the average version, we may simply take . Moreover, we note that Theorem 1 holds for both averaging or for choosing at random from . This means that calculating the duality gap at few random points would lead to the same type of guarantee with high probability. This approach has the advantage over averaging, since it is easier to implement the stopping condition (we simply check the duality gap at some random stopping points. This is in contrast to averaging in which we need to know in advance).
The above theorem applies to the hinge-loss function, . However, for the hinge-loss, the constant in the first inequality can be replaced by (this is because the domain of the dual variables is positive, hence the constant in Lemma 4 can be replaced by ). We therefore obtain the bound:
If we choose , and assume that , then the second part of Theorem 2 implies a requirement of
which is slightly weaker than the first part of Theorem 2 when is relatively large.
Using SGD at the first epoch
We first introduce convenient notation. Let denote the primal objective for the first examples in the training set,
Note that is the primal objective given in (1) and that is the dual objective given in (2).
The following algorithm is a modification of SGD. The idea is to greedily decrease the dual sub-optimality for problem at each step . This is different from DCA which works with at each step .
Procedure Modified-SGD Initialize: Iterate: for : Find to maximize . Let return
We have the following result for the convergence of dual objective:
Assume that is -Lipschitz for all . In addition, assume that are iid samples from the same distribution for all . At the end of Procedure Modified-SGD, we have
Here the expectation is with respect to the random sampling of .
When is relatively large, the convergence rate in Theorem 3 for modified-SGD is better than what we can prove for SDCA. This is because Modified-SGD employs a larger step size at each step for than the corresponding step size in SDCA for . However, the proof requires us to assume that are randomly drawn from a certain distribution, while this extra randomness assumption is not needed for the convergence of SDCA.
Procedure SDCA with SGD Initialization Stage 1: call Procedure Modified-SGD and obtain Stage 2: call Procedure SDCA with parameter
For Lipschitz loss, ideally we would like to have a computational complexity of . Theorem 4 shows that SDCA with SGD at first epoch can achieve no worst than , which is very close to the ideal bound. The result is better than that of vanilla SDCA in Theorem 1 when is relatively large, which shows a complexity of . The difference is caused by small step-sizes in the vanilla SDCA, and its negative effect can be observed in practice. That is, the vanilla SDCA tends to have a slower convergence rate than SGD in the first few iterations when is relatively large.
Similar to Remark 2, for the hinge-loss, the constant in Theorem 4 can be reduced to 1, and the constant can be reduced to .
Refined Analysis for Almost Smooth Loss
Our analysis shows that for smooth loss, SDCA converges faster than SGD (linear versus sub-linear convergence). For non-smooth loss, the analysis does not show any advantage of SDCA over SGD. This does not explain the practical observation that SDCA converges faster than SGD asymptotically even for SVM. This section tries to refine the analysis for Lipschitz loss and shows potential advantage of SDCA over SGD asymptotically. Note that the refined analysis of this section relies on quantities that depend on the underlying data distribution, and thus the results are more complicated than those presented earlier. Although precise interpretations of these results will be complex, we will discuss them qualitatively after the theorem statements, and use them to explain the advantage of SDCA over SGD for non-smooth losses.
Although we note that for SVM, Luo and Tseng’s analysis shows linear convergence of the form for dual sub-optimality after passes over the data, as we mentioned, is proportional to the smallest nonzero eigenvalue of the data Gram matrix , and hence can be arbitrarily bad when two data points becomes very close to each other. Our analysis uses a completely different argument that avoids this dependency on the data Gram matrix.
The main intuition behind our analysis is that many non-smooth loss functions are nearly smooth everywhere. For example, the hinge loss is smooth at any point such that is not close to . Since a smooth loss has a strongly convex dual (and the strong convexity of the dual is directly used in our proof to obtain fast rate for smooth loss), the refined analysis in this section relies on the following refined dual strong convexity condition that holds for nearly everywhere smooth loss functions.
For each , we define so that for all dual variables and , and , we have
For the SVM loss, we have , and , with and . It follows that
Therefore we may take .
For the absolute deviation loss, we have , and with . It follows that .
Under the assumption of (4). Let , we have the following dual strong convexity inequality:
For SVM, we can take , and for the absolute deviation loss, we may take . Although some of can be close to zero, in practice, most will be away from zero, which means is strongly convex at nearly all points. Under this assumption, we may establish a convergence result for the dual sub-optimality.
where satisfies .
if is small, then Theorem 5 is superior to Theorem 1 for the convergence of the dual objective function. We consider three scenarios. The first scenario is when . If is small, and , then the convergence is linear. The second scenario is when there exists so that (for SVM, it means that for all ), and since , we again have a linear convergence of . In the third scenario, we assume that for some , we can take and obtain
The factor can be removed in this case with a slightly more complex analysis. This result is again superior to Theorem 1 for dual convergence.
The following result shows fast convergence of duality gap using Theorem 5.
This means that the convergence rate for duality gap in Theorem 6 is linear as implied by the linear convergence of in Theorem 5.
Examples
We will specify the SDCA algorithms for a few common loss functions. For simplicity, we only specify the algorithms without SGD initialization. In practice, instead of complete randomization, we may also run in epochs, and each epoch employs a random permutation of the data. We call this variant SDCA-Perm.
Procedure SDCA-Perm Let Let Iterate: for epoch Let be a random permutation of Iterate: for : Find to increase dual (*) Output (Averaging option): Let Let return Output (Random option): Let and for some random return
Hinge loss is used in SVM. We have and with . Absolute deviation loss is used in quantile regression. We have and with .
For the hinge loss, step (*) in Procedure SDCA-Perm has a closed form solution as
For absolute deviation loss, step (*) in Procedure SDCA-Perm has a closed form solution as
Both hinge loss and absolute deviation loss are -Lipschitz. Therefore, we expect a convergence behavior of no worse than
without SGD initialization based on Theorem 1. The refined analysis in Section 5 suggests a rate that can be significantly better, and this is confirmed with our empirical experiments.
Smooth loss
Squared loss is used in ridge regression. We have , and . Log loss is used in logistic regression. We have , and with .
For squared loss, step (*) in Procedure SDCA-Perm has a closed form solution as
For log loss, step (*) in Procedure SDCA-Perm does not have a closed form solution. However, one may start with the approximate solution,
and further use several steps of Newton’s update to get a more accurate solution.
Finally, we present a smooth variant of the hinge-loss, as defined below. Recall that the hinge loss function (for positive labels) is and we have with . Consider adding to the term which yields the -strongly convex function
Then, its conjugate, which is defined below, is -smooth. We refer to it as the smoothed hinge-loss (for positive labels):
For the smoothed hinge loss, step (*) in Procedure SDCA-Perm has a closed form solution as
Both log loss and squared loss are -smooth. The smoothed-hinge loss is smooth. Therefore we expect a convergence behavior of no worse than
This is confirmed in our empirical experiments.
Proofs
We denote by the set of sub-gradients of at . We use the notation to denote some sub-gradient of at . For convenience, we list the following simple facts about primal and dual formulations, which will used in the proofs. For each , we have
The proof of our basic results stated in Theorem 2 and Theorem 1 relies on the fact that for SDCA, it is possible to lower bound the expected increase in dual objective by the duality gap. This key observation is stated in Lemma 1. Note that the duality gap can be further lower bounded using dual suboptimality. Therefore Lemma 1 implies a recursion for dual suboptimality which can be solved to obtain the convergence of dual objective. We can then apply Lemma 1 again, and the convergence of dual objective implies an upper bound of the duality gap, which leads to the basic theorems. The more refined results in Section 4 and Section 5 use similar strategies but with Lemma 1 replaced by its variants.
The key lemma, which estimates the expected increase in dual objective in terms of the duality gap, can be stated as follows.
Assume that is -strongly-convex (where can be zero). Then, for any iteration and any we have
and .
Proof Since only the ’th element of is updated, the improvement in the dual objective can be written as
By the definition of the update we have for all that
Combining this with (8) and rearranging terms we obtain that
where we used which yields . Therefore
Therefore, if we take expectation of (10) w.r.t. the choice of we obtain that
Multiplying both sides by concludes the proof of the lemma.
For all , . In addition, .
Proof The first inequality is by weak duality, the second is by the optimality of , and the third by the assumption that . For the last inequality we use , which yields .
Equipped with the above lemmas we are ready to prove Theorem 2.
Proof [Proof of Theorem 2] The assumption that is -smooth implies that is -strongly-convex. We will apply Lemma 1 with . Recall that . Therefore, the choice of implies that , and hence for all . This yields,
But since and , we obtain that
This would be smaller than if
So, requiring we obtain a duality gap of at most . This means that we should require
which proves the first part of Theorem 2.
Next, we sum (12) over to obtain
Now, if we choose to be either the average vectors or a randomly chosen vector over , then the above implies
This implies the second part of Theorem 2, and concludes the proof.
2 Proof of Theorem 1
Next, we turn to the case of Lipschitz loss function. We rely on the following lemma.
Proof Fix some . By definition of the conjugate we have
A direct corollary of the above lemma is:
Suppose that for all , is -Lipschitz. Let be as defined in Lemma 1 (with ). Then, .
Proof Using Lemma 3 we know that , and in addition by the relation of Lipschitz and sub-gradients we have . Thus, , and the proof follows.
Proof [Proof of Theorem 1] Let and note that by Lemma 4 we have . Lemma 1, with , tells us that
for all . Indeed, let us choose , then at , we have
This implies that (14) holds at . For we use an inductive argument. Suppose the claim holds for , therefore
This provides a bound on the dual sub-optimality. We next turn to bound the duality gap. Summing (13) over and rearranging terms we obtain that
Now, if we choose to be either the average vectors or a randomly chosen vector over , then the above implies
If and , we can set and combining with (14) we obtain
We conclude the proof by noticing that using Lemma 2, which implies that .
3 Proof of Theorem 3
We assume that are randomly drawn from a distribution , and define the population optimizer
By definition, we have for any specific realization of . Therefore
where the expectation is with respect to the choice of examples, and note that both and are sample dependent.
After each step , we let , and let . We have, for all ,
The inequality above can be obtained by noticing that the choice of maximizes the dual objective. In the derivation of the equalities we have used basic algebra as well as the equation which follows from . Next we note that (where we used the triangle inequality, the definition of , and Lemma 3). Therefore,
Taking expectation with respect to the choice of the examples, and note that the ’th example does not depend on we obtain that
Using Lemma 2 we know that for all . Therefore, by summing the above over we obtain that
4 Proof of Theorem 4
5 Proof of Proposition 1
Consider any feasible dual variable and the corresponding . Since
Since , we have
By combining the previous two displayed inequalities, we obtain the first desired bound.
Next, we let , . Since and , it follows that and . Therefore
6 Proof of Theorem 5
The following lemma is very similar to Lemma 1 with nearly identical proof, but it focuses only on the convergence of dual objective function using (5).
Assume that (5) is valid. Then for any iteration and any we have
Proof Since only the ’th element of is updated, the improvement in the dual objective can be written as
By the definition of the update we have for all that
We can now apply the Jensen’s inequality to obtain
By summing over , we obtain
where the equality follows from . By rearranging the terms on the right hand side using , we obtain
Suppose that for all , is -Lipschitz. Let be as defined in Lemma 5. Then
Proof Similarly to the proof of Lemma 4, we know that . Moreover, , and when . Therefore there are no more than data points such that is positive. The desired result follows from these facts.
we have .
7 Proof of Theorem 6
where . It follows that given any , we have
where Lemma 4 is used for the last inequality. Since is arbitrary and , it follows that
Now plug into Lemma 1, we obtain for all :
By taking , and summing over , we obtain
Experimental Results
In this section we demonstrate the tightness of our theory. All our experiments are performed with the smooth variant of the hinge-loss defined in (7), where the value of is taken from the set . Note that for we obtain the vanilla non-smooth hinge-loss.
In the experiments, we use to denote the dual sub-optimality, and to denote the primal sub-optimality (note that this is different than the notation in our analysis which uses to denote the duality gap). It follows that is the duality gap.
The experiments were performed on three large datasets with very different feature counts and sparsity, which were kindly provided by Thorsten Joachims. The astro-ph dataset classifies abstracts of papers from the physics ArXiv according to whether they belong in the astro-physics section; CCAT is a classification task taken from the Reuters RCV1 collection; and cov1 is class 1 of the covertype dataset of Blackard, Jock & Dean. The following table provides details of the dataset characteristics.
2 Linear convergence for Smooth Hinge-loss
Our first experiments are with where we set . The goal of the experiment is to show that the convergence is indeed linear. We ran the SDCA algorithm for solving the regularized loss minimization problem with different values of regularization parameter . Figure 1 shows the results. Note that a logarithmic scale is used for the vertical axis. Therefore, a straight line corresponds to linear convergence. We indeed observe linear convergence for the duality gap.
3 Convergence for non-smooth Hinge-loss
Next we experiment with the original hinge loss, which is -Lipschitz but is not smooth. We again ran the SDCA algorithm for solving the regularized loss minimization problem with different values of regularization parameter . Figure 2 shows the results. As expected, the overall convergence rate is slower than the case of a smoothed hinge-loss. However, it is also apparent that for large values of a linear convergence is still exhibited, as expected according to our refined analysis. The bounds plotted are based on Theorem 1, which are slower than what we observe, as expected from the refined analysis in Section 5.
4 Effect of smoothness parameter
We next show the effect of the smoothness parameter. Figure 3 shows the effect of the smoothness parameter on the rate of convergence. As can be seen, the convergence becomes faster as the loss function becomes smoother. However, the difference is more dominant when decreases.
Figure 4 shows the effect of the smoothness parameter on the zero-one test error. It is noticeable that even though the non-smooth hinge-loss is considered a tighter approximation of the zero-one error, in most cases, the smoothed hinge-loss actually provides a lower test error than the non-smooth hinge-loss. In any case, it is apparent that the smooth hinge-loss decreases the zero-one test error faster than the non-smooth hinge-loss.
5 Cyclic vs. Stochastic vs. Random Permutation
In Figure 5 we compare choosing dual variables at random with repetitions (as done in SDCA) vs. choosing dual variables using a random permutation at each epoch (as done in SDCA-Perm) vs. choosing dual variables in a fixed cyclic order (that was chosen once at random). As can be seen, a cyclic order does not lead to linear convergence and yields actual convergence rate much slower than the other methods and even worse than our bound. As mentioned before, some of the earlier analyses such as can be applied both to stochastic and to cyclic dual coordinate ascent methods with similar results. This means that their analysis, which can be no better than the behavior of cyclic dual coordinate ascent, is inferior to our analysis. Finally, we also observe that SDCA-Perm is sometimes faster than SDCA.
6 Comparison to SGD
We next compare SDCA to Stochastic Gradient Descent (SGD). In particular, we implemented SGD with the update rule , where is chosen uniformly at random and denotes a sub-gradient of . One clear advantage of SDCA is the availability of a clear stopping condition (by calculating the duality gap). In Figure 6 and Figure 7 we present the primal sub-optimality of SDCA, SDCA-Perm, and SGD. As can be seen, SDCA converges faster than SGD in most regimes. SGD can be better if both is high and one performs a very small number of epochs. This is in line with our theory of Section 4. However, SDCA quickly catches up.
In Figure 8 we compare the zero-one test error of SDCA, when working with the smooth hinge-loss () to the zero-one test error of SGD, when working with the non-smooth hinge-loss. As can be seen, SDCA with the smooth hinge-loss achieves the smallest zero-one test error faster than SGD.