RES: Regularized Stochastic BFGS Algorithm
Aryan Mokhtari, Alejandro Ribeiro
I Introduction
Recourse to quasi-Newton methods then arises as a natural alternative. Indeed, quasi-Newton methods achieve superlinear convergence rates in deterministic settings while relying on gradients to compute curvature estimates . Since unbiased gradient estimates are computable at manageable cost, stochastic generalizations of quasi-Newton methods are not difficult to devise . Numerical tests of these methods on simple quadratic objectives suggest that stochastic quasi-Newton methods retain the convergence rate advantages of their deterministic counterparts . The success of these preliminary experiments notwithstanding, stochastic quasi-Newton methods are prone to yield near singular curvature estimates that may result in erratic behavior (see Section V-A).
In this paper we introduce a stochastic regularized version of the Broyden-Fletcher-Goldfarb-Shanno (BFGS) quasi-Newton method to solve problems with the generic structure in (1). The proposed regularization avoids the near-singularity problems of more straightforward extensions and yields an algorithm with provable convergence guarantees when the functions are strongly convex.
We begin the paper with a brief discussion of SGD (Section II) and deterministic BFGS (Section II-A). The fundamental idea of BFGS is to continuously satisfy a secant condition that captures information on the curvature of the function being minimized while staying close to previous curvature estimates. To regularize deterministic BFGS we retain the secant condition but modify the proximity condition so that eigenvalues of the Hessian approximation matrix stay above a given threshold (Section II-A). This regularized version is leveraged to introduce the regularized stochastic BFGS algorithm (Section II-B). Regularized stochastic BFGS differs from standard BFGS in the use of a regularization to make a bound on the largest eigenvalue of the Hessian inverse approximation matrix and on the use of stochastic gradients in lieu of deterministic gradients for both, the determination of descent directions and the approximation of the objective function’s curvature. We abbreviate regularized stochastic BFGS as RESThe letters “R and “E” appear in “regularized” as well as in the names of Broyden, Fletcher, and Daniel Goldfarb; “S” is for “stochastic” and Shanno..
Convergence properties of RES are then analyzed (Section III). We prove that lower and upper bounds on the Hessians of the sample functions are sufficient to guarantee convergence to the optimal argument with probability 1 over realizations of the sample functions (Theorem 1). We complement this result with a characterization of the convergence rate which is shown to be at least linear in expectation (Theorem 2). Linear expected convergence rates are typical of stochastic optimization algorithms and, in that sense, no better than SGD. Advantages of RES relative to SGD are nevertheless significant, as we establish in numerical results for the minimization of a family of quadratic objective functions of varying dimensionality and condition number (Section IV). As we vary the condition number we observe that for well conditioned objectives RES and SGD exhibit comparable performance, whereas for ill conditioned functions RES outperforms SGD by an order of magnitude (Section IV-A). As we vary problem dimension we observe that SGD becomes unworkable for large dimensional problems. RES however, exhibits manageable degradation as the number of iterations required for convergence doubles when the problem dimension increases by a factor of ten (Section IV-C).
An important example of a class of problems having the form in (1) are support vector machines (SVMs) that reduce binary classification to the determination of a hyperplane that separates points in a given training set; see, e.g., . We adapt RES for SVM problems (Section V) and show the improvement relative to SGD in convergence time, stability, and classification accuracy through numerical analysis (SectionV-A). We also compare RES to standard (non-regularized) stochastic BFGS. The regularization in RES is fundamental in guaranteeing convergence as standard (non-regularized) stochastic BFGS is observed to routinely fail in the computation of a separating hyperplane.
II Algorithm definition
Introducing now a time index , an initial iterate , and a step size sequence , a stochastic gradient descent algorithm is defined by the iteration
A customary step size choice for which (5) holds is to make , for given parameters and that control the initial step size and its speed of decrease, respectively. Convergence notwithstanding, the number of iterations required to approximate is very large in problems that don’t have small condition numbers. This motivates the alternative methods we discuss in subsequent sections.
To speed up convergence of (4) resort to second order methods is of little use because evaluating Hessians of the objective function is computationally intensive. A better suited methodology is the use of quasi-Newton methods whereby gradient descent directions are premultiplied by a matrix ,
The idea is to select positive definite matrices close to the Hessian of the objective function . Various methods are known to select matrices , including those by Broyden e.g., ; Davidon, Feletcher, and Powell (DFP) ; and Broyden, Fletcher, Goldfarb, and Shanno (BFGS) e.g., . We work here with the matrices used in BFGS since they have been observed to work best in practice .
In BFGS – and all other quasi-Newton methods for that matter – the function’s curvature is approximated by a finite difference. Specifically, define the variable and gradient variations at time as
respectively, and select the matrix to be used in the next time step so that it satisfies the secant condition . The rationale for this selection is that the Hessian satisfies this condition for tending to . Notice however that the secant condition is not enough to completely specify . To resolve this indeterminacy, matrices in BFGS are also required to be as close as possible to in terms of the Gaussian differential entropy,
The constraint in (II-A) restricts the feasible space to positive semidefinite matrices whereas the constraint requires to satisfy the secant condition. The objective represents the differential entropy between random variables with zero-mean Gaussian distributions and having covariance matrices and . The differential entropy is nonnegative and equal to zero if and only if . The solution of the semidefinite program in (II-A) is therefore closest to in the sense of minimizing the Gaussian differential entropy among all positive semidefinite matrices that satisfy the secant condition .
Strongly convex functions are such that the inner product of the gradient and variable variations is positive, i.e., . In that case the matrix in (II-A) is explicitly given by the update – see, e.g., and the proof of Lemma 1 –,
In principle, the solution to (II-A) could be positive semidefinite but not positive definite, i.e., we can have but . However, through direct operation in (9) it is not difficult to conclude that stays positive definite if the matrix is positive definite. Thus, initializing the curvature estimate with a positive definite matrix guarantees for all subsequent times . Still, it is possible for the smallest eigenvalue of to become arbitrarily close to zero which means that the largest eigenvalue of can become arbitrarily large. This has been proven not to be an issue in BFGS implementations but is a more significant challenge in the stochastic version proposed here.
To avoid this problem we introduce a regularization of (II-A) to enforce the eigenvalues of to exceed a positive constant . Specifically, we redefine as the solution of the semidefinite program,
The curvature approximation matrix defined in (II-A) still satisfies the secant condition but has a different proximity requirement since instead of comparing and we compare and . While (II-A) does not ensure that all eigenvalues of exceed we can show that this will be the case under two minimally restrictive assumptions. We do so in the following proposition where we also give an explicit solution for (II-A) analogous to the expression in (9) that solves the non regularized problem in (II-A).
Consider the semidefinite program in (II-A) where the matrix is positive definite and define the corrected gradient variation
Furthermore, is explicitly given by the expression
II-B RES: Regularized Stochastic BFGS
by using instead of . The Hessian approximation for the next iteration is defined as the matrix that satisfies the stochastic secant condition and is closest to in the sense of (II-A). As per Proposition 1 we can compute explicitly as
III Convergence
Our goal here is to show that as time progresses the sequence of variable iterates approaches the optimal argument . In proving this result we make the following assumptions.
The second moment of the norm of the stochastic gradient is bounded for all . i.e., there exists a constant such that for all variables it holds
For given and define the mean instantaneous Hessian as the average Hessian value along the segment
Using the definitions of the mean instantaneous Hessian in (25) as well as the definitions of the stochastic gradient variations and variable variations in (15) and (7) we can rewrite (III) as
The claim in (23) follows from (27) and (28). Indeed, consider the ratio of inner products and use (27) and the first inequality in (28) to write
Consider the RES algorithm as defined by (14)-(17). If assumptions 1, 2 and 3 hold true, the sequence of average function satisfies
where the constant .
We proceed to bound the third term in the right hand side of (34). Start by observing that the 2-norm of a product is not larger than the product of the 2-norms and that, as noted above, with given the matrix is also given to write
We now find a lower bound for the second term in the right hand side of (III). Since the Hessian approximation matrices are positive definite their inverses are positive semidefinite. In turn, this implies that all the eigenvalues of are not smaller than since increases all the eigenvalues of by . This lower bound for the eigenvalues of implies that
Substituting the lower bound in (38) for the corresponding summand in (III) and further noting the definition of in the statement of the lemma, the result in (33) follows.
Consider the RES algorithm as defined by (14)-(17). If assumptions 1, 2 and 3 hold true and the sequence of stepsizes satisfies (5), the limit infimum of the squared Euclidean distance to optimality satisfies
Proof : The proof uses the relationship in the statement (32) of Lemma 2 to build a supermartingale sequence. For that purpose define the stochastic process with values
Observe that is well defined because the is summable. Further define the sequence with values
Let now be a sigma-algebra measuring , , and . The conditional expectation of given can be written as
because the term is just a deterministic constant. Substituting (32) of Lemma 2 into (42) and using the definitions of in (40) and in (41) yields
Since the sequences and are nonnegative it follows from (43) that they satisfy the conditions of the supermartingale convergence theorem – see e.g. theorem E . Therefore, we conclude that: (i) The sequence converges almost surely. (ii) The sum is almost surely finite. Using the explicit form of in (41) we have that is equivalent to
Since the sequence of stepsizes is nonsummable for (44) to be true we need to have a vanishing subsequence embedded in . By definition, this miles that the limit infimum of the sequence is null,
To transform the gradient bound in (45) into a bound pertaining to the squared distance to optimality simply observe that the lower bound on the eigenvalues of applied to a Taylor’s expansion around the optimal argument implies that
Observe now that since is the minimizing argument of we must have for all . Using this fact and reordering terms we simplify (46) to
Further observe that the Cauchy-Schwarz inequality implies that . Substitution of this bound in (47) and simplification of a factor yields
Since the limit infimum of is null as stated in (45) the result in (39) follows from considering the bound in (48) in the limit as the iteration index .
We complement the convergence result in Theorem 1 with a characterization of the expected convergence rate that we introduce in the following theorem.
Consider the RES algorithm as defined by (14)-(17) and let the sequence of step sizes be given by with the parameter sufficiently small and the parameter sufficiently large so as to satisfy the inequality
Theorem 2 shows that under specified assumptions, the expected error in terms of the objective value after RES iterations is of order . This implies that the rate of convergence for RES is at least linear in expectation. Linear expected convergence rates are typical of stochastic optimization algorithms and, in that sense, no better than conventional SGD. While the convergence rate doesn’t change, improvements in convergence time are marked as we illustrate with the numerical experiments of sections IV and V-A.
IV Numerical analysis
For a given we study the convergence metric
which represents the time needed to achieve a given relative distance to optimality as measured in terms of the number of stochastic functions that are processed to achieve such accuracy.
To study the effect of the problem’s condition number we generate instances of (IV) by choosing uniformly at random from the box and the matrix as diagonal with elements uniformly drawn from the discrete set . This choice of yields problems with condition number .
As expected for a problem with a large condition number RES is much faster than SGD. After the distance to optimality for the SGD iterate is . Comparable accuracy for RES is achieved after iterations. Since we are using for RES this corresponds to random function evaluations. Conversely, upon processing random functions – which corresponds to iterations – RES achieves accuracy . This relative performance difference can be made arbitrarily large by modifying the condition number of .
A more comprehensive analysis of the relative advantages of RES appears in figs. 2 and 3. We keep the same parameters used to generate Fig. 1 except that we use for Fig. 2 and for Fig. 3. This yields a family of well-condition functions with condition number and a family of ill-conditioned functions with condition number . In both figures we consider and study the convergence times and of RES and SGD, respectively [cf. (53)]. Resulting empirical distributions of and across instances of the functions in (IV) are reported in figs. 2 and 3 for the well conditioned and ill conditioned families, respectively. For the well conditioned family RES reduces the number of functions processed from an average of in the case of SGD to an average of . This nondramatic improvement becomes more significant for the ill conditioned family where the reduction is from an average of for SGD to an average of for RES. The spread in convergence times is also smaller for RES.
IV-B Choice of stochastic gradient average
The trends in convergence times apparent in Fig. 4 are: (i) As we increase the variance of convergence times decreases. (ii) The average convergence time decreases as we go from small to moderate values of and starts increasing as we go from moderate to large values of . Indeed, the empirical standard deviations of convergence times decrease monotonically from to , , , and , when increases from to , , , and . The empirical mean decreases from to as we move from to , stays at about the same value for and then increases to and for and . This behavior is expected since increasing results in curvature estimates closer to the Hessian thereby yielding better convergence times. As we keep increasing , there is no payoff in terms of better curvature estimates and we just pay a penalty in terms of more function evaluations for an equally good matrix. This can be corroborated by observing that the convergence times are about half those of which in turn are about half those of . This means that the actual convergence times have similar distributions for , , and . The empirical distributions in Fig. 4 show that moderate values of suffice to provide workable curvature approximations. This justifies the use in sections IV-A and IV-C
IV-C Effect of problem’s dimension
To evaluate performance for problems of different dimensions we consider functions of the form in (IV) with uniformly chosen from the box and diagonal matrix as in Section IV-A. However, we select the elements as uniformly drawn from the interval $n$ grows.
The variability parameter for the random vector is set to . The RES parameters are , , and . For SGD we use . In both methods the step size sequence is with and . For a problem of dimension we study convergence times and of RES and SGD as defined in (53) with . For each value of considered we determine empirical distributions of and across problem instances. If we report and interpret this outcome as a convergence failure. The resulting histograms are shown in Fig. 5 for , , , and .
For problems of small dimension having the average performances of RES and SGD are comparable, with SGD performing slightly better. E.g., the medians of these times are and , respectively. A more significant difference is that times of RES are more concentrated than times of SGD. The latter exhibits large convergence times with probability and fails to converge altogether in a few rare instances – we have in 1 out of 1,000 realizations. In the case of RES all realizations of are in the interval .
As we increase we see that RES retains the smaller spread advantage while eventually exhibiting better average performance as well. Medians for are still comparable at and , as well as for at and . For the RES median is decidedly better since and .
For large dimensional problems having SGD becomes unworkable. It fails to achieve convergence in iterations with probability and exceeds iterations with probability . For RES we fail to achieve convergence in iterations with probability and achieve convergence in less than iterations in all other cases. Further observe that RES degrades smoothly as increases. The median number of gradient evaluations needed to achieve convergence increases by a factor of as we increase by a factor of . The spread in convergence times remains stable as grows.
V Support vector machines
where we also added the regularization term for some constant . The vector in (54) balances the minimization of the sum of distances to the separating hyperplane, as measured by the loss function , with the minimization of the norm to enforce desirable properties in . Common selections for the loss function are the hinge loss , the squared hinge loss and the log loss . See, e.g., .
In order to model (54) as a stochastic optimization problem in the form of problem (1), we define as a given training point and as a uniform probability distribution on the training set . Upon defining the sample functions
it follows that we can rewrite the objective function in (54) as
since each of the functions is drawn with probability according to the definition of . Substituting (56) into (54) yields a problem with the general form of (1) with random functions explicitly given by (55).
The specific form of Step 5 is obtained by replacing for in (V). We analyze the behavior of Algorithm (1) in the implementation of a SVM in the following section.
An illustration of the relative performances of SGD and RES for is presented in Fig. 6. The value of the objective function is represented with respect to the number of feature vectors processed, which is given by the product between the iteration index and the sample size used to compute stochastic gradients. This is done because the sample sizes in RES () and SGD () are different. The curvature correction of RES results in significant reductions in convergence time. E.g., RES achieves an objective value of upon processing of feature vectors. To achieve the same objective value SGD processes feature vectors. Conversely, after processing feature vectors the objective values achieved by RES and SGD are and , respectively.
The performance difference between the two methods is larger for feature vectors of larger dimension . The plot of the value of the objective function with respect to the number of feature vectors processed is shown in Fig. 7 for . The convergence time of RES increases but is still acceptable. For SGD the algorithm becomes unworkable. After processing RES reduces the objective value to while SGD has barely made progress at .
Differences in convergence times translate into differences in classification accuracy when we process all vectors in the training set. This is shown for dimension and training set size in Fig. 8. To build Fig. 8 we process feature vectors with RES and SGD with the same parameters used in Fig. 6. We then use these vectors to classify observations in the test set and record the percentage of samples that are correctly classified. The process is repeated times to estimate the probability distribution of the correct classification percentage represented by the histograms shown. The dominance of RES with respect to SGD is almost uniform. The vector computed by SGD classifies correctly at most of the of the feature vectors in the test set. The vector computed by RES exceeds this accuracy with probability . Perhaps more relevant, the classifier computed by RES achieves a mean classification accuracy of which is not far from the clairvoyant classification accuracy of . Although performance is markedly better in general, RES fails to compute a working classifier with probability . We omit comparison of classification accuracy for due to space considerations. As suggested by Fig. 7 the differences are more significant than for the case .
We also investigate the difference between regularized and non-regularized versions of stochastic BFGS for feature vectors of dimension . Observe that non-regularized stochastic BFGS corresponds to making and in Algorithm 1. To illustrate the advantage of the regularization induced by the proximity requirement in (II-A), as opposed to the non regularized proximity requirement in (II-A), we keep a constant stepsize . The corresponding evolutions of the objective function values with respect to the number of feature vectors processed are shown in Fig. 9 along with the values associated with stochastic gradient descent. As we reach convergence the likelihood of having small eigenvalues appearing in becomes significant. In regularized stochastic BFGS (RES) this results in recurrent jumps away from the optimal classifier . However, the regularization term limits the size of the jumps and further permits the algorithm to consistently recover a reasonable curvature estimate. In Fig. 9 we process feature vectors and observe many occurrences of small eigenvalues. However, the algorithm always recovers and heads back to a good approximation of . In the absence of regularization small eigenvalues in result in larger jumps away from . This not only sets back the algorithm by a much larger amount than in the regularized case but also results in a catastrophic deterioration of the curvature approximation matrix . In Fig. 9 we observe recovery after the first two occurrences of small eigenvalues but eventually there is a catastrophic deviation after which non-regularized stochastic BFSG behaves not better than SGD.
VI Conclusions
Convex optimization problems with stochastic objectives were considered. RES, a stochastic implementation of a regularized version of the Broyden-Fletcher-Goldfarb-Shanno quasi-Newton method was introduced to find corresponding optimal arguments. Almost sure convergence was established under the assumption that sample functions have well behaved Hessians. A linear convergence rate in expectation was further proven. Numerical results showed that RES affords important reductions in terms of convergence time relative to stochastic gradient descent. These reductions are of particular significance for problems with large condition numbers or large dimensionality since RES exhibits remarkable stability in terms of the total number of iterations required to achieve target accuracies. An application of RES to support vector machines was also developed. In this particular case the advantages of RES manifest in improvements of classification accuracies for training sets of fixed cardinality. Future research directions include the development of limited memory versions as well as distributed versions where the function to be minimized is spread over agents of a network.
Appendix A: Proof of Proposition 1
We first show that (13) is true. Since the optimization problem in (II-A) is convex in we can determine the optimal variable using Lagrangian duality. Introduce then the multiplier variable associated with the secant constraint in (II-A) and define the Lagrangian
The dual function is defined as and the optimal dual variable is . We further define the primal Lagrangian minimizer associated with dual variable as
Observe that combining the definitions in (59) and (Appendix A: Proof of Proposition 1) we can write the dual function as
We will determine the optimal Hessian approximation as the Lagrangian minimizer associated with the optimal dual variable . To do so we first find the Lagrangian minimizer (59) by nulling the gradient of with respect to in order to show that must satisfy
Multiplying the equality in (61) by from the right and rearranging terms it follows that the inverse of the argument of the log-determinant function in (Appendix A: Proof of Proposition 1) can be written as
If, instead, we multiply (61) by from the right it follows after rearranging terms that
Further considering the trace of both sides of (63) and noting that we can write the trace in (Appendix A: Proof of Proposition 1) as
Observe now that since the trace of a product is invariant under cyclic permutations of its arguments and the matrix is symmetric we have . Since the argument in the latter is a scalar the trace operation is inconsequential from where it follows that we can rewrite (64) as
Observing that the log-determinant of a matrix is the opposite of the log-determinant of its inverse we can substitute (62) for the argument of the log-determinant in (Appendix A: Proof of Proposition 1). Further substituting (65) for the trace in (Appendix A: Proof of Proposition 1) and rearranging terms yields the explicit expression for the dual function
In order to compute the optimal dual variable we set the gradient of (66) to zero and manipulate terms to obtain
Applying the Sherman-Morrison formula to compute the inverse of the right hand side of (68) leads to
which can be verified by direct multiplication. The result in (13) follows after solving (69) for and noting that for the convex optimization problem in (II-A) we must have as we already argued.
Consider now the term and factorize from the left and right side so as to write
Define the vector and write as well as . Substituting these observation into (71) we can conclude that
because the eigenvalues of the matrix belong to the interval $\delta{\mathbf{I}}$. Since the rest add up to a positive semidefinite matrix it then must be that (12) is true.
Appendix B: Proof of Theorem 2
Let , and be given constants and be a nonnegative sequence that satisfies the inequality
for all times . The sequence is then bounded as
for all times , where the constant is defined as
Proof : We prove (74) using induction. To prove the claim for simply observe that the definition of in (75) implies that
because the maximum of two numbers is at least equal to both of them. By rearranging the terms in (76) we can conclude that
Comparing (77) and (74) it follows that the latter inequality is true for .
Introduce now the induction hypothesis that (74) is true for . To show that this implies that (74) is also true for substitute the induction hypothesis into the recursive relationship in (73). This substitution shows that is bounded as
Observe now that according to the definition of in (75), we know that because is the maximum of and . Reorder this bound to show that and substitute into (78) to write
Pulling out as a common factor and simplifying and reordering terms it follows that (79) is equivalent to
To complete the induction step use the difference of squares formula for to conclude that
Reordering terms in (81) it follows that \big{[}(s+t_{0})-1\big{]}/(s+t_{0})^{2}\leq 1/\big{[}(s+t_{0})+1\big{]}, which upon substitution into (80) leads to the conclusion that
Eq. (82) implies that the assumed validity of (74) for implies the validity of (74) for . Combined with the validity of (74) for , which was already proved, it follows that (74) is true for all times . ∎
Proof of Theorem 2: Consider the result in (32) of Lemma 2 and subtract the average function optimal value from both sides of the inequality to conclude that the sequence of optimality gaps in the RES algorithm satisfies
where, we recall, by definition.
We proceed to find a lower bound for the gradient norm in terms of the error of the objective value – this is a standard derivation which we include for completeness, see, e.g., . As it follows from Assumption 1 the eigenvalues of the Hessian are bounded between and as stated in (22). Taking a Taylor’s expansion of the objective function around and using the lower bound in the Hessian eigenvalues we can write
For fixed , the right hand side of (84) is a quadratic function of whose minimum argument we can find by setting its gradient to zero. Doing this yields the minimizing argument implying that for all we must have
The bound in (Appendix B: Proof of Theorem 2) is true for all and . In particular, for and (Appendix B: Proof of Theorem 2) yields
Rearrange terms in (86) to obtain a bound on the gradient norm squared . Further substitute the result in (83) and regroup terms to obtain the bound
Furhter substituting , which is the assumed form of the step size sequence by hypothesis, we can rewrite (88) as