Stochastic Quasi-Newton Methods for Nonconvex Stochastic Optimization
Xiao Wang, Shiqian Ma, Donald Goldfarb, Wei Liu
Introduction
In this paper, we consider the following stochastic optimization problem:
In this paper, we study stochastic quasi-Newton (SQN) methods for solving the nonconvex stochastic optimization problem (1.1). In the deterministic optimization setting, quasi-Newton methods are more robust and achieve higher accuracy than gradient methods, because they use approximate second-order derivative information. Quasi-Newton methods usually employ the following updates for solving (1.1):
where is an approximation to the Hessian matrix at , or is an approximation to . The most widely-used quasi-Newton method, the BFGS method updates via
where and . By using the Sherman-Morrison-Woodbury formula, it is easy to derive that the equivalent update to is
where . For stochastic optimization, there has been some work in designing stochastic quasi-Newton methods that update the iterates via (1.3) using the stochastic gradient in place of . Specific examples include the following. The adaptive subgradient (AdaGrad) method proposed by Duchi, Hazan and Singer , which takes to be a diagonal matrix that estimates the diagonal of the square root of the uncentered covariance matrix of the gradients, has been proven to be quite efficient in practice. In , Bordes, Bottou and Gallinari studied SGD with a diagonal rescaling matrix based on the secant condition associated with quasi-Newton methods. Roux and Fitzgibbon discussed the necessity of including both Hessian and covariance matrix information in a stochastic Newton type method. Byrd et al. proposed a quasi-Newton method that uses the sample average approximation (SAA) approach to estimate Hessian-vector multiplications. In , Byrd et al.proposed a stochastic limited-memory BFGS (L-BFGS) method based on SA, and proved its convergence for strongly convex problems. Stochastic BFGS and L-BFGS methods were also studied for online convex optimization by Schraudolph, Yu and Günter in . For strongly convex problems, Mokhtari and Ribeiro proposed a regularized stochastic BFGS method (RES) and analyzed its convergence in and studied an online L-BFGS method in . Recently, Moritz, Nishihara and Jordan proposed a linearly convergent method that integrates the L-BFGS method in with the variance reduction technique (SVRG) proposed by Johnson and Zhang in to alleviate the effect of noisy gradients. A related method that incorporates SVRG into a quasi-Newton method was studied by Lucchi, McWilliams and Hofmann in . In , Gower, Goldfarb and Richtárik proposed a variance reduced block L-BFGS method that converges linearly for convex functions. It should be noted that all of the above stochastic quasi-Newton methods are designed for solving convex or even strongly convex problems.
Challenges. The key challenge in designing stochastic quasi-Newton methods for nonconvex problem lies in the difficulty in preserving the positive-definiteness of (and ), due to the non-convexity of the problem and the presence of noise in estimating the gradient. It is known that the BFGS update (1.4) preserves the positive-definiteness of as long as the curvature condition
holds, which can be guaranteed for strongly convex problem. For nonconvex problem, the curvature condition (1.6) can be satisfied by performing a line search. However, doing this is no longer feasible for (1.1) in the stochastic setting, because exact function values and gradient information are not available. As a result, an important issue in designing stochastic quasi-Newton methods for nonconvex problems is how to preserve the positive-definiteness of (or ) without line search.
Our contributions. Our contributions (and where they appear) in this paper are as follows.
We propose a stochastic damped L-BFGS (SdLBFGS) method that fits into the proposed framework. This method adaptively generates a positive definite matrix that approximates the inverse Hessian matrix at the current iterate . Convergence and complexity results for this method are provided. Moreover, our method does not generate explicitly, and only its multiplication with vectors is computed directly. (See Section 3)
Motivated by the recent advance of SVRG for nonconvex minimization , we propose a variance reduced variant of SdLBFGS and analyze its -calls complexity. (See Section 4)
A general framework for stochastic quasi-Newton methods for nonconvex optimization
We now give some assumptions that are required throughout this paper.
where is the noise level of the gradient estimation, and , , are independent samples, and for a given the random variable is independent of .
Note that the stochastic BFGS methods studied in require that the noisy gradient is bounded, i.e.,
where is a constant. Our assumption (2.2) is weaker than (2.3).
Analogous to deterministic quasi-Newton methods, our SQN method takes steps
where is defined as a mini-batch estimate of the gradient:
and denotes the random variable generated by the -th sampling in the -th iteration. From AS.2 we can see that has the following properties:
There exist two positive constants such that
We denote by , the random samplings in the -th iteration, and denote by , the random samplings in the first iterations. Since is generated iteratively based on historical gradient information by a random process, we make the following assumption on to control the randomness (note that is given in the initialization step).
For any , the random variable depends only on .
It then follows directly from AS.4 and (2.6) that
where the expectation is taken with respect to generated in the computation of .
We will not specify how to compute until Section 3, where a specific updating scheme for satisfying both assumptions AS.3 and AS.4 will be proposed.
We now present our SQN method for solving (1.1) as Algorithm 2.1.
In this subsection, we analyze the convergence and complexity of SQN under the condition that the step size in (2.4) is diminishing. Specifically, in this subsection we assume satisfies the following condition:
which is a standard assumption in stochastic approximation algorithms (see, e.g., ). One very simple choice of that satisfies (2.8) is .
The following lemma shows that a descent property in terms of the expected objective value holds for SQN. Our analysis is similar to analyses that have been used in .
Suppose that is generated by SQN and assumptions AS.1-4 hold. Further assume that (2.8) holds, and for all . (Note that this can be satisfied if is non-increasing and the initial step size ). Then the following inequality holds
where the conditional expectation is taken with respect to .
Define . From (2.4), and assumptions AS.1 and AS.3, we have
Taking expectation with respect to on both sides of (2.10) conditioned on , we obtain,
which together with (2.11) and AS.3 yields that
Then (2.13) combined with the assumption implies (2.9). ∎
Before proceeding further, we introduce the definition of a supermartingale (see for more details).
We are now ready to give convergence results for SQN (Algorithm 2.1).
Suppose that assumptions AS.1-4 hold for generated by SQN with batch size for all . If the stepsize satisfies (2.8) and for all , then it holds that
Moreover, there exists a positive constant such that
Define and . Let be the -algebra measuring , and . From (2.9) we know that for any , it holds that
Since , it follows that (2.14) holds. ∎
Under the assumption (2.3) used in , we now prove a stronger convergence result showing that any limit point of generated by SQN is a stationary point of (1.1) with probability 1.
Assume the same assumptions hold as in Theorem 2.1, and that (2.3) holds. Then
For any given , according to (2.14), there exist infinitely many iterates such that . Then if (2.18) does not hold, there must exist two infinite sequences of indices , with , such that for
where the last inequality is due to (2.3) and the convexity of . Then it follows from (2.21) that
which together with (2.20) implies that with probability 1, as . Hence, from the Lipschitz continuity of , it follows that with probability 1 as . However, this contradicts (2.19). Therefore, the assumption that (2.18) does not hold is not true. ∎
Note that our result in Theorem 2.2 is stronger than the ones given in existing works such as and . Moreover, although Bottou also proves that the SA method for nonconvex stochastic optimization with diminishing stepsize is almost surely convergent to stationary point, our analysis requires weaker assumptions. For example, assumes that the objective function is three times continuously differentiable, while our analysis does not require this. Furthermore, we are able to analyze the iteration complexity of SQN, for a specifically chosen step size (see Theorem 2.3 below), which is not provided in .
We now analyze the iteration complexity of SQN.
Suppose that assumptions AS.1-4 hold for generated by SQN with batch size for all . We also assume that is specifically chosen as
with . Note that this choice satisfies (2.8) and for all . Then
Taking expectation on both sides of (2.9) and summing over yields
Since , it follows that the number of iterations needed is at most . ∎
Note that Theorem 2.3 also provides iteration complexity analysis for the classic SGD method, which can be regarded as a special case of SQN with . To the best of our knowledge, our complexity result in Theorem 2.3 is new for both SGD and stochastic quasi-Newton methods.
2 Complexity of SQN with random output and constant step size
Suppose that assumptions AS.1-4 hold, and that in SQN (Algorithm 2.1) is chosen such that for all with for at least one . Moreover, for a given integer , let be a random variable with the probability mass function
where and the expectation is taken with respect to and . Moreover, if we choose and for all , then (2.25) reduces to
where . Now summing and noticing that , yields
It follows from the definition of in (2.24) that
which together with (2.28) implies (2.25). ∎
Note that in Theorem 2.4, ’s are not required to be diminishing, and they can be constant as long as they are upper bounded by .
We now show that the complexity of SQN with random output and constant step size is .
Assume the conditions in Theorem 2.4 hold, and and for all . Let be the total number of -calls needed to calculate stochastic gradients in SQN (Algorithm 2.1). For a given accuracy tolerance , we assume that
Note that the number of iterations of SQN is at most . Obviously, . From (2.26) we have that
In Corollary 2.5 we did not consider the -calls that are involved in updating in line 3 of SQN. In the next section, we consider a specific updating scheme to generate , and analyze the total -calls complexity of SQN including the generation of the .
Stochastic damped L-BFGS method
In this section, we propose a specific way, namely a damped L-BFGS method (SdLBFGS), to generate in SQN (Algorithm 2.1) that satisfies assumptions AS.3 and AS.4. We also provide an efficient way to compute without generating explicitly.
Before doing this, we first describe a stochastic damped BFGS method as follows. We generate an auxiliary stochastic gradient at using the samplings from the -st iteration:
Note that we assume that our can separate two arguments and in the stochastic gradient and generate an output . The stochastic gradient difference is defined as
The iterate difference is still defined as . We then define
Note that if , then . Our stochastic damped BFGS approach updates as
According to the Sherman-Morrison-Woodbury formula, this corresponds to updating as
where . The following lemma shows that the damped BFGS updates (3.4) and (3.5) preserve the positive definiteness of and .
For defined in (3.2), . Moreover, if , then and generated by the damped BFGS updates (3.4) and (3.5) are both positive definite.
given that . Therefore, both and defined in (3.5) and (3.4) are positive definite. ∎
where . The output is then used as the estimate of the inverse Hessian at to compute the search direction at the -th iteration. It can be shown that if the sequence of pairs satisfy the curvature condition , , then is positive definite provided that is positive definite. Recently, stochastic L-BFGS methods have been proposed for solving strongly convex problems in . However, the theoretical convergence analyses in these papers do not apply to nonconvex problems. We now show how to design a stochastic damped L-BFGS formula for nonconvex problems.
Suppose that in the past iterations the algorithm generated and that satisfy
Then at the current iterate, we compute and by (3.1). Since may not be positive, motivated by the stochastic damped BFGS update (3.2)-(3.5), we define a new vector as
Using and , , we define the stochastic damped L-BFGS formula as
where . As in the analysis in Lemma 3.1, by induction we can show that , . Note that when , we use and , to execute the stochastic damped L-BFGS update.
We next discuss the choice of . A popular choice in the standard L-BFGS method is to set . Since may not be positive for nonconvex problems, we set
To prove that generated by (3.9)-(3.10) satisfies assumptions AS.3 and AS.4, we need to make the following assumption.
The function is twice continuously differentiable with respect to . The stochastic gradient is computed as , and there exists a positive constant such that , for any .
Note that AS.5 is equivalent to requiring that , rather than the strong convexity assumption required in . The following lemma shows that the eigenvalues of are bounded below away from zero under assumption AS.5.
Suppose that AS.5 holds. Given defined in (3.10), suppose that is updated through the stochastic damped L-BFGS formula (3.9). Then all the eigenvalues of satisfy
According to Lemma 3.1, , . To prove that the eigenvalues of are bounded below away from zero, it suffices to prove that the eigenvalues of are bounded from above. From the damped L-BFGS formula (3.9), can be computed recursively as
starting from . Since , Lemma 3.1 indicates that for . Moreover, the following inequalities hold:
From the definition of in (3.7) and the facts that and from (3.10), we have that for any
where , because . Therefore, for any , from (3.13), and the facts that and , and the assumption AS.5 it follows that
We now prove that is uniformly bounded above.
Suppose that the assumption AS.5 holds. Given defined in (3.10), suppose that is updated through the stochastic damped L-BFGS formula (3.9). Then satisfies
where , and and denote, respectively, the maximum eigenvalue and operator norm of .
For notational simplicity, let , , , , . Now (3.5) can be written as
Using the facts that for any vectors and , , and , which follows from (3.14), we have that
Noting that , it follows that
Lemmas 3.2 and 3.3 indicate that generated by (3.7)-(3.9) satisfies assumption AS.3. Moreover, since defined in (3.1) does not depend on random samplings in the -th iteration, it follows that depends only on and assumption AS.4 is satisfied.
To analyze the cost of computing the step direction , note that from (3.9), can be represented as
which is the same as the classical L-BFGS formula in (3.6), except that is replaced by . Hence, we can compute the step direction by the two-loop recursion, implemented in the following procedure.
We now analyze the computational cost of Procedure 3.1. In Step 2, the computation of involves and , which take multiplications. In Step 3, from the definition of in (3.7), since has been obtained in a previous step, one only needs to compute and some scalar-vector products, thus the computation of takes multiplications. Due to the fact that
all involved computations have been done for . Furthermore, the first loop Steps 4-7 involves scalar-vector multiplications and vector inner products. So does the second loop Steps 9-12. Including the product , the whole procedure takes multiplications.
Notice that in Step 1 of Procedure 3.1, the computation of involves the evaluation of , which requires -calls. As a result, when Procedure 3.1 is plugged into SQN (Algorithm 2.1), the total number of -calls needed in the -th iteration becomes . This leads to the following overall -calls complexity result for our stochastic damped L-BFGS method.
SdLBFGS with a Variance Reduction Technique
Motivated by the recent advance of SVRG for nonconvex minimization proposed in and , we now present a variance reduced SdLBFGS method, which we call SdLBFGS-VR, for solving (1.2). Here, the mini-batch stochastic gradient is defined as , where the subsample set is randomly chosen from . SdLBFGS-VR allows a constant step size, and thus can accelerate the convergence speed of SdLBFGS. SdLBFGS-VR is summarized in Algorithm 4.1.
We now analyze the -calls complexity of Algorithm 4.1. We first analyze the convergence rate of SdLBFGS-VR, essentially following .
Suppose assumptions AS.1, AS.2 and AS.5 hold. Set . It holds that
It follows from AS.1 and the fact that , for any , which follows under assumption AS.5, from Lemmas 3.2 and 3.3, that,
Moreover, for any , since is an unbiased estimate of , it holds that,
Furthermore, the following inequality holds:
Combining (4.2), (4.3) and (4.4) yields that,
Suppose assumptions AS.1, AS.2 and AS.5 hold. Set , . Suppose that there exist two positive constants such that
holds. Set , and .
Denote . It then follows that , and , where is the Euler’s number. Because , for any , we have
From Theorem 4.1, it follows that to obtain an -solution, the outer iteration number of Algorithm 4.1 should be in the order of which is due to the fact that . As a result, the total number of component gradient evaluations is , which is . ∎
Numerical Experiments
In this section, we empirically study the performance of the proposed SdLBFGS and SdLBFGS-VR methods. We compare SdLBFGS with SGD with given by (2.5) using a diminishing step size in both methods, for solving the following nonconvex support vector machine (SVM) problem with a sigmoid loss function, which has been considered in :
In Figure 5.1 we compare the performance of SGD and SdLBFGS with various memory sizes . The batch size was set to and the stepsize to both and for SGD and for SdLBFGS. In the left figure we plot the squared norm of the gradient (SNG) versus the number of iterations, up to a total of . The SNG was computed using randomly generated testing points as:
In Figure 5.2, we report the performance of SdLBFGS with different used in (3.10). From Figure 5.2 we see that SdLBFGS performs best with small such as and .
In Figure 5.3 we report the effect of the batch size on the performance of SGD and SdLBFGS with memory size . For SdLBFGS, the left figure shows that gives the best performance among the three choices 50, 100 and 500, tested, with respect to the total number of iterations taken. This is because a larger batch size leads to gradient estimation with lower variance. The right figure shows that if the total number of -calls is fixed, then because of the tradeoff between the number of iterations and the batch size, i.e., because the number of iterations is proportional to the reciprocal of the batch size, the SdLBFGS variant corresponding to slightly outperforms the variant.
In Figure 5.4, we report the percentage of correctly classified data for randomly generated testing points. The results are consistent with the one shown in the left figure of Figure 5.3, i.e., the ones with a lower squared norm of the gradient give a higher percentage of correctly classified data.
Moreover, we also counted the number of steps taken by SdLBFGS in which . We set the total number of iterations to 1000 and tested the effect of the memory size and batch size of SdLBFGS on the number of such steps. For fixed batch size , the average numbers of such steps over 10 runs of SdLBFGS were respectively equal to when the memory sizes were . For fixed memory size , the average numbers of such steps over 10 runs of SdLBFGS were respectively equal to when the batch sizes are . Therefore, the number of such steps roughly decreases as the memory size and the batch size increase. This is to be expected because as increases, there is less negative effect caused by “limited-memory”; and as increases, the gradient estimation has lower variance.
2 Numerical results for SdLBFGS on the RCV1 dataset
In this subsection, we compare SGD and SdLBFGS for solving (5.1) on a real dataset: RCV1 , which is a collection of newswire articles produced by Reuters in 1996-1997. In our tests, we used a subset downloaded from http://www.cad.zju.edu.cn/home/dengcai/Data/TextData.html of RCV1 used in that contains 9625 articles with 29992 distinct words. The articles are classified into four categories “C15”, “ECAT”, “GCAT” and “MCAT”, each with 2022, 2064, 2901 and 2638 articles respectively. We consider the binary classification problem of predicting whether or not an article is in the second and fourth category, i.e., the entry of each label vector is 1 if a given article appears in category “MCAT” or “ECAT”, and -1 otherwise. We used 60% of the articles (5776) as training data and the remaining 40% (3849) as testing data.
In Figure 5.5, we compare SdLBFGS with various memory sizes and SGD on the RCV1 dataset. For SGD and SdLBFGS, we use the stepsize: and the batch size . We also used a second stepsize of for SGD. Note that the SNG computed via (5.3) uses testing data. The left figure shows that for the RCV1 data set, increasing the memory size improves the performance of SdLBFGS. The performance of SdLBFGS with memory sizes was similar, although for it was slightly better. The right figure also shows that larger memory sizes can achieve higher correct classification percentages.
In Figure 5.6, we report the performance of SdLBFGS on RCV1 dataset with different used in (3.10). Similar to Figure 5.2, we see from Figure 5.6 that SdLBFGS works best for small such as and .
Figure 5.7 compares SGD and SdLBFGS with different batch sizes. The stepsize of SGD and SdLBFGS was set to and , respectively. The memory size of SdLBFGS was chosen as . We tested SGD with batch size , and SdLBFGS with batch size . From Figure 5.7 we can see that SGD performs worse than SdLBFGS. For SdLBFGS, from Figure 5.7 (a) we observe that larger batch sizes give better results in terms of SNG. If we fix the total number of -calls to , SdLBFGS with performs the worst among the different batch sizes and exhibits dramatic oscillation. The performance gets much better when the batch size becomes larger. In this set of tests, the performance with was slightly better than . One possible reason is that for the same number of -calls, a smaller batch size leads to larger number of iterations and thus gives better results.
In Figure 5.8, we report the percentage of correctly classified data points for both SGD and SdLBFGS with different batch sizes. These results are consistent with the ones in Figure 5.7. Roughly speaking, the algorithm that gives a lower SNG leads to a higher percentage of correctly classified data points.
We also counted the number of steps taken by SdLBFGS in which . We again set the total number of iterations of SdLBFGS to 1000. For fixed batch size , the average numbers of such steps over 10 runs of SdLBFGS were respectively equal to when the memory sizes were . For fixed memory size , the average numbers of such steps over 10 runs of SdLBFGS were respectively equal to when the batch sizes were . This is qualitatively similar to our observations in Section 5.1, except that for the fixed batch size , a fewer number of such steps were required by the SdLBFGS variants with memory sizes and compared with and .
3 Numerical results for SdLBFGS-VR on the RCV1 dataset
Figure 5.9 compares the performance of SdLBFGS-VR with different memory size . It shows that the limited-memory BFGS improves performance, even when . Moreover, larger memory size usually provides better performance, but the difference is not very significant.
Figure 5.10 compares the performance of SdLBFGS-VR with different batch sizes and shows that SdLBFGS-VR is not very sensitive to . In these tests, we always set .
The impact of step size on SdLBFGS-VR and SVRG is shown in Figure 5.11 for three step sizes: and . Clearly, for the same step size, SdLBFGS-VR gives better result than SVRG. From our numerical tests, we also observed that neither SdLBFGS-VR nor SVRG is stable when .
In Figure 5.12, we report the performance of SdLBFGS-VR with different constant step sizes , for and SdLBFGS with different diminishing step sizes for , since SdLBFGS needs a diminishing step size to guarantee convergence. We see there that SdLBFGS-VR usually performs better than SdLBFGS. The performance of SdLBFGS with is in fact already very good, but still inferior to SdLBFGS-VR. This indicates that the variance reduction technique is indeed helpful.
4 Numerical results of SdLBFGS-VR on MNIST dataset
Conclusions
In this paper we proposed a general framework for stochastic quasi-Newton methods for nonconvex stochastic optimization. Global convergence, iteration complexity, and -calls complexity were analyzed under different conditions on the step size and the output of the algorithm. Specifically, a stochastic damped limited memory BFGS method was proposed, which falls under the proposed framework and does not generate explicitly. The damping technique was used to preserve the positive definiteness of , without requiring the original problem to be convex. A variance reduced stochastic L-BFGS method was also proposed for solving the empirical risk minimization problem. Encouraging numerical results were reported for solving nonconvex classification problems using SVM and neural networks.
Acknowledgement
The authors are grateful to two anonymous referees for their insightful comments and constructive suggestions that have improved the presentation of this paper greatly. The authors also thank Conghui Tan for helping conduct the numerical tests in Section 5.4.