Stochastic Nested Variance Reduction for Nonconvex Optimization
Dongruo Zhou, Pan Xu, Quanquan Gu
Introduction
We study the following nonconvex finite-sum problem
In this work, we mainly focus on first-order algorithms, which only need the function value and gradient evaluations. We use gradient complexity, the number of stochastic gradient evaluations, to measure the convergence of different first-order algorithms.While we use gradient complexity as in to present our result, it is basically the same if we use incremental first-order oracle (IFO) complexity used by . In other words, these are directly comparable. For nonconvex optimization, it is well-known that Gradient Descent (GD) can converge to an -approximate stationary point with number of stochastic gradient evaluations. It can be seen that GD needs to calculate the full gradient at each iteration, which is a heavy load when . Stochastic Gradient Descent (SGD) has gradient complexity to an -approximate stationary point under the assumption that the stochastic gradient has a bounded variance . While SGD only needs to calculate a mini-batch of stochastic gradients in each iteration, due to the noise brought by stochastic gradients, its gradient complexity has a worse dependency on . In order to improve the dependence of the gradient complexity of SGD on and for nonconvex optimization, variance reduction technique was firstly proposed in for convex finite-sum optimization. Representative algorithms include Stochastic Average Gradient (SAG) , Stochastic Variance Reduced Gradient (SVRG) , SAGA , Stochastic Dual Coordinate Ascent (SDCA) , Finito , Batching SVRG and SARAH , to mention a few. The key idea behind variance reduction is that the gradient complexity can be saved if the algorithm use history information as reference. For instance, one representative variance reduction method is SVRG, which is based on a semi-stochastic gradient that is defined by two reference points. Since the the variance of this semi-stochastic gradient will diminish when the iterate gets closer to the minimizer, it therefore accelerates the convergence of stochastic gradient method. Later on, Harikandeh et al. proposed Batching SVRG which also enjoys fast convergence property of SVRG without computing the full gradient. The convergence of SVRG under nonconvex setting was first analyzed in , where is still convex but each component function can be nonconvex. The analysis for the general nonconvex function was done by , which shows that SVRG can converge to an -approximate stationary point with number of stochastic gradient evaluations. This result is strictly better than that of GD. Recently, Lei et al. proposed a Stochastically Controlled Stochastic Gradient (SCSG) based on variance reduction, which further reduces the gradient complexity of SVRG to . This result outperforms both GD and SGD strictly. To the best of our knowledge, this is the state-of-art gradient complexity under the smoothness (i.e., gradient lipschitz) and bounded stochastic gradient variance assumptions. A natural and long standing question is:
Is there still room for improvement in nonconvex finite-sum optimization without making additional assumptions beyond smoothness and bounded stochastic gradient variance?
In this paper, we provide an affirmative answer to the above question, by showing that the dependence on in the gradient complexity of SVRG and SCSG can be further reduced. We propose a novel algorithm namely Stochastic Nested Variance-Reduced Gradient descent (SNVRG). Similar to SVRG and SCSG, our proposed algorithm works in a multi-epoch way. Nevertheless, the technique we developed is highly nontrivial. At the core of our algorithm is the multiple reference points-based variance reduction technique in each iteration. In detail, inspired by SVRG and SCSG, which uses two reference points to construct a semi-stochastic gradient with diminishing variance, our algorithm uses reference points to construct a semi-stochastic gradient, whose variance decays faster than that of the semi-stochastic gradient used in SVRG and SCSG.
Our major contributions are summarized as follows:
We propose a stochastic nested variance reduction technique for stochastic gradient method, which reduces the dependence of the gradient complexity on compared with SVRG and SCSG.
We show that our proposed algorithm is able to achieve an -approximate stationary point with stochastic gradient evaluations, which outperforms all existing first-order algorithms such as GD, SGD, SVRG and SCSG.
As a by-product, when is a -gradient dominated function, a variant of our algorithm can achieve an -approximate global minimizer (i.e., ) within \widetilde{O}\big{(}n\wedge\tau\epsilon^{-1}+\tau(n\wedge\tau\epsilon^{-1})^{1/2}\big{)} stochastic gradient evaluations, which also outperforms the state-of-the-art.
2 Additional Related Work
Since it is hardly possible to review the huge body of literature on convex and nonconvex optimization due to space limit, here we review some additional most related work on accelerating nonconvex (finite-sum) optimization.
Acceleration by high-order smoothness assumption With only Lipschitz continuous gradient assumption, Carmon et al. showed that the lower bound for both deterministic and stochastic algorithms to achieve an -approximate stationary point is . With high-order smoothness assumptions, i.e., Hessian Lipschitzness, Hessian smoothness etc., a series of work have shown the existence of acceleration. For instance, Agarwal et al. gave an algorithm based on Fast-PCA which can achieve an -approximate stationary point with gradient complexity Carmon et al. showed two algorithms based on finding exact or inexact negative curvature which can achieve an -approximate stationary point with gradient complexity . In this work, we only consider gradient Lipschitz without assuming Hessian Lipschitz or Hessian smooth. Therefore, our result is not directly comparable to the methods in this category.
Acceleration by momentum The fact that using momentum is able to accelerate algorithms has been shown both in theory and practice in convex optimization . However, there is no evidence that such acceleration exists in nonconvex optimization with only Lipschitz continuous gradient assumption . If satisfies -strongly nonconvex, i.e., , Allen-Zhu proved that Natasha , an algorithm based on nonconvex momentum, is able to find an -approximate stationary point in . Later, Allen-Zhu further showed that Natasha 2, an online version of Natasha 1, is able to achieve an -approximate stationary point within stochastic gradient evaluationsIn fact, Natasha 2 is guaranteed to converge to an -approximate second-order stationary point with gradient complexity, which implies the convergence to an -approximate stationary point..
After our paper was submitted to NIPS and released on arXiv, a paper was released on arXiv after our work, which independently proposes a different algorithm and achieves the same convergence rate for finding an -approximate stationary point.
To give a thorough comparison of our proposed algorithm with existing first-order algorithms for nonconvex finite-sum optimization, we summarize the gradient complexity of the most relevant algorithms in Table 1. We also plot the gradient complexities of different algorithms in Figure 1 for nonconvex smooth functions. Note that GD and SGD are always worse than SVRG and SCSG according to Table 1. In addition, GNC-AGD and Natasha2 needs additional Hessian Lipschitz condition. Therefore, we only plot the gradient complexity of SVRG, SCSG and our proposed SNVRG in Figure 1.
Preliminaries
In this section, we present some definitions that will be used throughout our analysis.
is called the upper bound on the variance of stochastic gradients .
We also consider a class of functions namely gradient dominated functions , which is formally defined as follows:
Note that gradient dominated condition is also known as the Polyak-Lojasiewicz (P-L) condition , and is not necessarily convex. It is weaker than strong convexity as well as other popular conditions that appear in the optimization literature .
The Proposed Algorithm
In this section, we present our nested stochastic variance reduction algorithm, namely, SNVRG.
One-epoch-SNVRG: We first present the key component of our main algorithm, One-epoch-SNVRG, which is displayed in Algorithm 1. The most innovative part of Algorithm 1 attributes to the reference points and reference gradients. Note that when , Algorithm 1 reduces to one epoch of SVRG algorithm . To better understand our One-epoch SNVRG algorithm, it would be helpful to revisit the original SVRG which is a special case of our algorithm. For the finite-sum optimization problem in (1.1), the original SVRG takes the following updating formula
where is the step size, is a random index uniformly chosen from and is a snapshot for after every iterations. There are two reference points in the update formula at : and . Note that is updated every iterations, namely, is set to be only when . Moreover, in the semi-stochastic gradient , there are also two reference gradients and we denote them by and .
Back to our One-epoch-SNVRG, we can define similar reference points and reference gradients as that in the special case of SVRG. Specifically, for , each point has reference points , which is set to be with index defined as
Specially, note that we have and for all . Similarly, also has reference gradients , which can be defined based on the reference points :
where are random index sets with and are uniformly generated from without replacement. Based on the reference points and reference gradients, we then update , where and is the step size parameter. The illustration of reference points and gradients of SNVRG is displayed in Figure 2.
We remark that it would be a huge waste for us to re-evaluate at each iteration. Fortunately, due to the fact that each reference point is only updated after a long period, we can maintain and only need to update when has been updated as is suggested by Line 24 in Algorithm 1.
SNVRG: Using One-epoch-SNVRG (Algorithm 1) as a building block, we now present our main algorithm: Algorithm 2 for nonconvex finite-sum optimization to find an -approximate stationary point. At each iteration of Algorithm 2, it executes One-epoch-SNVRG (Algorithm 1) which takes as its input and outputs . We choose as the output of Algorithm 2 uniformly from , for .
SNVRG-PL: In addition, when function in (1.1) is gradient dominated as defined in Definition 2.6 (P-L condition), it has been proved that the global minimum can be found by SGD , SVRG and SCSG very efficiently. Following a similar trick used in , we present Algorithm 3 on top of Algorithm 2, to find the global minimum in this setting. We call Algorithm 3 SNVRG-PL, because gradient dominated condition is also known as Polyak-Lojasiewicz (PL) condition .
Space complexity: We briefly compare the space complexity between our algorithms and other variance reduction based algorithms. SVRG and SCSG needs space complexity to store one reference gradient, SAGA needs to store reference gradients for each component functions, and its space complexity is without using any trick. For our algorithm SNVRG, we need to store reference gradients, thus its space complexity is . In our theory, we will show that . Therefore, the space complexity of our algorithm is actually , which is almost comparable to that of SVRG and SCSG.
Main Theory
In this section, we provide the convergence analysis of SNVRG.
We first analyze One-epoch-SNVRG (Algorithm 1) and provide a particular choice of parameters.
Suppose that has averaged -Lipschitz gradient, in Algorithm 1, suppose and let the number of nested loops be . Choose the step size parameter as . For the loop and batch parameters, let and
for all . Then the output of Algorithm 1 satisfies
within stochastic gradient computations, where , is a constant and is the indicator function.
The following theorem shows the gradient complexity for Algorithm 2 to find an -approximate stationary point with a constant base batch size .
stochastic gradient computations, where .
If we treat and as constants, and assume , then (4.2) can be simplified to . This gradient complexity is strictly better than , which is achieved by SCSG . Specifically, when , our proposed SNVRG is faster than SCSG by a factor of ; when , SNVRG is faster than SCSG by a factor of . Moreover, SNVRG also outperforms Natasha 2 which attains gradient complexity and needs the additional Hessian Lipschitz condition.
2 Convergence of SNVRG-PL
We now consider the case when is a -gradient dominated function. In general, we are able to find an -approximate global minimizer of instead of only an -approximate stationary point. Algorithm 3 uses Algorithm 2 as a component.
stochastic gradient computations, where
If we treat , and as constants, then the gradient complexity in (4.3) turns into . Compared with nonconvex SVRG which achieves gradient complexity, our SNVRG-PL is strictly better than SVRG in terms of the first summand and is faster than SVRG at least by a factor of in terms of the second summand. Compared with a more general variant of SVRG, namely, the SCSG algorithm , which attains \widetilde{O}\big{(}n\wedge\tau\epsilon^{-1}+\tau(n\wedge\tau\epsilon^{-1})^{2/3}\big{)} gradient complexity, SNVRG-PL also outperforms it by a factor of .
If we further assume that is -strongly convex, then it is easy to verify that is also -gradient dominated. As a direct consequence, we have the following corollary:
Under the same conditions and parameter choices as Theorem 4.4. If we additionally assume that is -strongly convex, then Algorithm 3 will outputs an -approximate global minimizer within
stochastic gradient computations, where is the condition number of .
Corollary 4.6 suggests that when we regard and as constants and set , Algorithm 3 is able to find an -approximate global minimizer within stochastic gradient computations, which matches SVRG-lep in Katyusha X . Using catalyst techniques or Katyusha momentum , it can be further accelerated to , which matches the best-known convergence rate .
Experiments
In this section, we compare our algorithm SNVRG with other baseline algorithms on training a convolutional neural network for image classification. We compare the performance of the following algorithms: SGD; SGD with momentum (denoted by SGD-momentum); ADAM; SCSG . It is worth noting that SCSG is a special case of SNVRG when the number of nested loops . Due to the memory cost, we did not compare GD and SVRG which need to calculate the full gradient. Although our theoretical analysis holds for general nested loops, it suffices to choose in SNVRG to illustrate the effectiveness of the nested structure for the simplification of implementation. In this case, we have reference points and gradients. All experiments are conducted on Amazon AWS p2.xlarge servers which comes with Intel Xeon E5 CPU and NVIDIA Tesla K80 GPU (12G GPU RAM). All algorithm are implemented in Pytorch platform version within Python .
Datasets We use three image datasets: (1) The MNIST dataset consists of handwritten digits and has training examples and test examples. The digits have been size-normalized to fit the network, and each image is 28 pixels by 28 pixels. (2) CIFAR10 dataset consists of images in 10 classes and has training examples and test examples. The digits have been size-normalized to fit the network, and each image is 32 pixels by 32 pixels. (3) SVHN dataset consists of images of digits and has training examples and test examples. The digits have been size-normalized to fit the network, and each image is 32 pixels by 32 pixels.
CNN Architecture We use the standard LeNet , which has two convolutional layers with 6 and 16 filters of size 5 respectively, followed by three fully-connected layers with output size 120, 84 and 10. We apply max pooling after each convolutional layer.
Implementation Details & Parameter Tuning We did not use the random data augmentation which is set as default by Pytorch, because it will apply random transformation (e.g., clip and rotation) at the beginning of each epoch on the original image dataset, which will ruin the finite-sum structure of the loss function. We set our grid search rules for all three datasets as follows. For SGD, we search the batch size from and the initial step sizes from . For SGD-momentum, we set the momentum parameter as . We search its batch size from and the initial learning rate from . For ADAM, we search the batch size from and the initial learning rate from . For SCSG and SNVRG, we choose loop parameters which satisfy automatically. In addition, for SCSG, we set the batch sizes , where is the batch size ratio parameter. We search from and we search from . We search its initial learning rate from . For our proposed SNVRG, we set the batch sizes , where is the batch size ratio parameter. We search from and from . We search its initial learning rate from . Following the convention of deep learning practice, we apply learning rate decay schedule to each algorithm with the learning rate decayed by every 20 epochs. We also conducted experiments based on plain implementation of different algorithms without learning rate decay, which is deferred to the appendix.
We plotted the training loss and test error for different algorithms on each dataset in Figure 3. The results on MNIST are presented in Figures 3(a) and 3(d); the results on CIFAR10 are in Figures 3(b) and 3(e); and the results on SVHN dataset are shown in Figures 3(c) and 3(f). It can be seen that with learning rate decay schedule, our algorithm SNVRG outperforms all baseline algorithms, which confirms that the use of nested reference points and gradients can accelerate the nonconvex finite-sum optimization.
We would like to emphasize that, while this experiment is on training convolutional neural networks, the major goal of this experiment is to illustrate the advantage of our algorithm and corroborate our theory, rather than claiming a state-of-the-art algorithm for training deep neural networks.
Conclusions and Future Work
In this paper, we proposed a stochastic nested variance reduced gradient method for finite-sum nonconvex optimization. It achieves substantially better gradient complexity than existing first-order algorithms. This partially resolves a long standing question that whether the dependence of gradient complexity on for nonconvex SVRG and SCSG can be further improved. There is still an open question: whether is the optimal gradient complexity for finite-sum and stochastic nonconvex optimization problem? For finite-sum nonconvex optimization problem, the lower bound has been proved in Fang et al. , which suggests that our algorithm is near optimal up to a logarithmic factor. However, for general stochastic problem, the lower bound is still unknown. We plan to derive such lower bound in our future work. On the other hand, our algorithm can also be extended to deal with nonconvex nonsmooth finite-sum optimization using proximal gradient .
Acknowledgement
We would like to thank the anonymous reviewers for their helpful comments. This research was sponsored in part by the National Science Foundation IIS-1652539 and BIGDATA IIS-1855099. We also thank AWS for providing cloud computing credits associated with the NSF BIGDATA award. The views and conclusions contained in this paper are those of the authors and should not be interpreted as representing any funding agencies.
References
Appendix A Proof of the Main Theoretical Results
In this section, we provide the proofs of our main theories in Section 4.
We first prove our key lemma on One-epoch-SNVRG. In order to prove Lemma 4.1, we need the following supporting lemma:
Let . If the step size and batch size parameters in Algorithm 1 satisfy and , then the output of Algorithm 1 satisfies
Note that , we can easily check that the choice of in Lemma 4.1 satisfies the assumption of Lemma A.1. Moreover, we have
We now submit (A.2) into (A.1), which immediately implies (4.1).
Next we compute how many stochastic gradient computations we need in total after we run One-epoch-SNVRG once. According to the update of reference gradients in Algorithm 1, we only update once at the beginning of Algorithm 1 (Line 4), which needs stochastic gradient computations. For , we only need to update it when , and thus we need to sample for times. We need stochastic gradient computations for each sampling procedure (Line 24 in Algorithm 1). We use to represent the total number of stochastic gradient computations, then based on above arguments we have
Now we calculate under the parameter choice of Lemma 4.1. Note that we can easily verify the following results:
Submit (A.4) into (A.3) yields the following results:
Therefore, the total gradient complexity is bounded as follows.
A.2 Proof of Theorem 4.2
Now we prove our main theorem which spells out the gradient complexity of SNVRG.
where . Taking summation for (A.7) over from to , we have
Dividing both sides of (A.8) by , we immediately obtain
where (A.9) holds because and by the definition . By the choice of parameters in Theorem 4.2, we have , which implies
A.3 Proof of Theorem 4.4
We then prove the main theorem on gradient complexity of SNVRG under gradient dominance condition (Algorithm 3).
Following the proof of Theorem 4.2, we obtain a similar inequality with (A.9):
where the second inequality holds due to the choice of parameters and for Algorithm 3 in Theorem 4.4. By (A.14) we can derive
Appendix B Proof of Key Lemma A.1
In this section, we focus on proving Lemma A.1 which plays a pivotal role in proving our main theorems. Let be the parameters as defined in Algorithm 1. We denote . We define filtration . Let be the reference points and reference gradients in Algorithm 1. We define as
We first present the following definition and two technical lemmas for the purpose of our analysis.
We define constant series as the following. For each , we define as
When , we define by induction:
For any , where and , we define
for simplification. Then we have the following results:
Let be vectors satisfying . Let be a uniform random subset of with size , then
where the second inequality comes from Lemma B.2 with we take . Moreover we have
where (B.5) holds because of Lemma B.3. Plug (B.6) into (B.4) and note that we have , and then we obtain
where . Divide both sides of (B.7) by , then Lemma A.1 holds trivially. ∎
Appendix C Proof of Technical Lemmas
In this section, we provide the proofs of technical lemmas used in Appendix B.
Let be the parameters defined in Algorithm 1 and be the reference points and reference gradients defined in Algorithm 1. Let be the variables and filtration defined in Appendix B and let be the constant series defined in Definition B.1.
In order to prove Lemma B.2, we will need the following supporting propositions and lemmas. We first state the proposition about the relationship among and :
Let be defined as in (B.1). Let satisfy . For any satisfying , it holds that
The following lemma spells out the relationship between and . In a word, is about times less than :
If and , then it holds that
Next lemma is a special case of Lemma B.2 with :
Suppose satisfies . If , then we have
Let be as defined in (3.1), then we have , and
We use mathematical induction to prove that Lemma B.2 holds for any . When , the statement holds because of Lemma C.3. Suppose that for , Lemma B.2 holds for any which satisfies . We need to prove Lemma B.2 still holds for and , where satisfies . We first define for simplification, then we choose , and we set indices and as
It can be easily verified that the following relationship also holds:
where the last inequality holds because of the induction hypothesis that Lemma B.2 holds for and . Note that we have from Proposition C.1, which implies
Next we bound as the following:
Adding up inequalities(C.15) and (C.12) together yields
We now telescope the above inequality for to , then we have
Since , and , we have
Therefore, we have proved that Lemma B.2 still holds for and . Then by mathematical induction, we have for all and which satisfy , Lemma B.2 holds. ∎
C.2 Proof of Lemma B.3
The following proof is adapted from that of Lemma A.1 in Lei et al. . We provide the proof here for the self-containedness of our paper.
We only consider the case when . Let , then we have
Appendix D Proofs of the Auxiliary Lemmas
In this section, we present the additional proofs of supporting lemmas used in Appendix C. Let and be the parameters defined in Algorithm 1. Let be the reference points and reference gradients used in Algorithm 1. Finally, are the variables and filtration defined in Appendix B and are the constant series defined in Definition B.1.
By the definition of reference point in (3.1), we can easily verify that (C.1) holds trivially.
Next we prove (C.2). Note that by (C.1) we have . For any , it is also true that by (3.1), which means and share the same first reference points. Then by the update rule of in Algorithm 1, we will maintain unchanged from time step to . In other worlds, we have for all .
We now prove the last claim (C.3). Based on (B.1) and (C.2), we have . Since for any , we have the following equations by the update in Algorithm 1 (Line 18).
Then for any , we have
where the first equality holds because of the definition of , the second equality holds due to (D.1) , the third equality holds due to (C.2) and the last equality holds due to (B.1). This completes the proof of (C.3). ∎
D.2 Proof of Lemma C.2
For any fixed , it can be seen that from the definition in (B.3), is monotonically decreasing with . In order to prove (C.4), we only need to compare and . Furthermore, by the definition of series in (B.3), it can be inducted that when ,
where (D.4) holds because for any , (D.5) holds due to the definition of in (B.2) and and (D.6) holds because . Recall that is monotonically decreasing with and the inequality in (D.6). Thus for all and , we have
where the third inequality holds because when and the last equation comes from the definition of in (B.2). This completes the proof of (C.4).
Using similar techniques, we can obtain the upper bound for which is similar to inequality (D.6) with replaced by . Therefore, we have
D.3 Proof of Lemma C.3
Now we prove Lemma C.3, which is a special case of Lemma B.2 if we choose .
where (D.9) is due to the -smoothness of , which can be verified as follows
(D.10) holds because . Further by Young’s inequality, we obtain
where the second inequality holds because . Now we bound the term . By (D.8) we have
Adding up inequalities (D.12) and (D.11), we get
where the last inequality holds due to the fact that by Lemma C.2. Next we bound with . Note that by (D.8), we have
Next we bound . First, by Lemma C.4 we have
Since , and , we have
where (D.17) holds because we have by Definition B.1. Telescoping (D.17) for to , we have
D.4 Proof of Lemma C.4
If , we have and . In this case the statement in Lemma C.4 holds trivially. Therefore, we assume in the following proof. Note that
Therefore, we can apply Lemma B.3 to (D.20) and obtain
Next we turn to bound term . Note that
where the last equation is due to the definition of . Plugging and into (D.19) yields the following result:
Appendix E Additional Experimental Results
We also conducted experiments comparing different algorithms without the learning rate decay schedule. The parameters are tuned by the same grid search described in Section 5. In particular, we summarize the parameters of different algorithms used in our experiments with and without learning rate decay for MNIST in Table 2, CIFAR10 in Table 3, and SVHN in Table 4. We plotted the training loss and test error for each dataset without learning rate decay in Figure 4. The results on MNIST are presented in Figures 4(a) and 4(d); the results on CIFAR10 are in Figures 4(b) and 4(e); and the results on SVHN dataset are shown in Figures 4(c) and 4(f). It can be seen that without learning decay, our algorithm SNVRG still outperforms all the baseline algorithms except for the training loss on SVHN dataset. However, SNVRG still performs the best in terms of test error on SVHN dataset. These results again suggest that SNVRG can beat the state-of-the-art in practice, which backups our theory.
Appendix F An Equivalent Version of Algorithm 1
Recall the One-epoch-SNVRG algorithm in Algorithm 1. Here we present an equivalent version of Algorithm 1 using nested loops, which is displayed in Algorithm 4 and is more aligned with the illustration in Figure 2. Note that the notation used in Algorithm 4 is slightly different from that in Algorithm 1 to avoid confusion.