Limited-memory BFGS (L-BFGS orLM-BFGS) is anoptimizationalgorithm in the collection ofquasi-Newton methods that approximates theBroyden–Fletcher–Goldfarb–Shanno algorithm (BFGS) using a limited amount ofcomputer memory.[1] It is a popular algorithm for parameter estimation inmachine learning.[2][3] The algorithm's target problem is to minimize over unconstrained values of the real-vector where is a differentiable scalar function.
Like the original BFGS, L-BFGS uses an estimate of the inverseHessian matrix to steer its search through variable space, but where BFGS stores a dense approximation to the inverse Hessian (n being the number of variables in the problem), L-BFGS stores only a few vectors that represent the approximation implicitly. Due to its resulting linear memory requirement, the L-BFGS method is particularly well suited for optimization problems with many variables. Instead of the inverse HessianHk, L-BFGS maintains a history of the pastm updates of the positionx and gradient ∇f(x), where generally the history sizem can be small (often). These updates are used to implicitly do operations requiring theHk-vector product.
The algorithm starts with an initial estimate of the optimal value,, and proceeds iteratively to refine that estimate with a sequence of better estimates. The derivatives of the function are used as a key driver of the algorithm to identify the direction of steepest descent, and also to form an estimate of the Hessian matrix (second derivative) of.
L-BFGS shares many features with other quasi-Newton algorithms, but is very different in how the matrix-vector multiplication is carried out, where is the approximate Newton's direction, is the current gradient, and is the inverse of the Hessian matrix. There are multiple published approaches using a history of updates to form this direction vector. Here, we give a common approach, the so-called "two loop recursion."[4][5]
We take as given, the position at thek-th iteration, and where is the function being minimized, and all vectors are column vectors. We also assume that we have stored the lastm updates of the form
We define, and will be the 'initial' approximate of the inverse Hessian that our estimate at iterationk begins with.
The algorithm is based on the BFGS recursion for the inverse Hessian as
For a fixedk we define a sequence of vectors as and. Then a recursive algorithm for calculating from is to define and. We also define another sequence of vectors as. There is another recursive algorithm for calculating these vectors which is to define and then recursively define and. The value of is then our ascent direction.
Thus we can compute thedescent direction as follows:
This formulation gives the search direction for the minimization problem, i.e.,. For maximization problems, one should thus take-z instead. Note that the initial approximate inverse Hessian is chosen as adiagonal matrix or even a multiple of the identity matrix since this is numerically efficient.
The scaling of the initial matrix ensures that the search direction is well scaled and therefore the unit step length is accepted in most iterations. AWolfe line search is used to ensure that the curvature condition is satisfied and the BFGS updating is stable. Note that some software implementations use an Armijobacktracking line search, but cannot guarantee that the curvature condition will be satisfied by the chosen step since a step length greater than may be needed to satisfy this condition. Some implementations address this by skipping the BFGS update when is negative or too close to zero, but this approach is not generally recommended since the updates may be skipped too often to allow the Hessian approximation to capture important curvature information. Some solvers employ so called damped (L)BFGS update which modifies quantities and in order to satisfy the curvature condition.
The two-loop recursion formula is widely used by unconstrained optimizers due to its efficiency in multiplying by the inverse Hessian. However, it does not allow for the explicit formation of either the direct or inverse Hessian and is incompatible with non-box constraints. An alternative approach is thecompact representation, which involves a low-rank representation for the direct and/or inverse Hessian.[6] This represents the Hessian as a sum of a diagonal matrix and a low-rank update. Such a representation enables the use of L-BFGS in constrained settings, for example, as part of the SQP method.
L-BFGS has been called "the algorithm of choice" for fittinglog-linear (MaxEnt) models andconditional random fields with-regularization.[2][3]
Since BFGS (and hence L-BFGS) is designed to minimizesmooth functions withoutconstraints, the L-BFGS algorithm must be modified to handle functions that include non-differentiable components or constraints. A popular class of modifications are called active-set methods, based on the concept of theactive set. The idea is that when restricted to a small neighborhood of the current iterate, the function and constraints can be simplified.
TheL-BFGS-B algorithm extends L-BFGS to handle simple box constraints (aka bound constraints) on variables; that is, constraints of the formli ≤xi ≤ui whereli andui are per-variable constant lower and upper bounds, respectively (for eachxi, either or both bounds may be omitted).[7][8] The method works by identifying fixed and free variables at every step (using a simple gradient method), and then using the L-BFGS method on the free variables only to get higher accuracy, and then repeating the process.
Orthant-wise limited-memory quasi-Newton (OWL-QN) is an L-BFGS variant for fitting-regularized models, exploiting the inherentsparsity of such models.[3]It minimizes functions of the form
where is adifferentiableconvexloss function. The method is an active-set type method: at each iterate, it estimates thesign of each component of the variable, and restricts the subsequent step to have the same sign. Once the sign is fixed, the non-differentiable term becomes a smooth linear term which can be handled by L-BFGS. After an L-BFGS step, the method allows some variables to change sign, and repeats the process.
Schraudolphet al. present anonline approximation to both BFGS and L-BFGS.[9] Similar tostochastic gradient descent, this can be used to reduce the computational complexity by evaluating theerror function and gradient on a randomly drawn subset of the overall dataset in each iteration. It has been shown that O-LBFGS has a global almost sure convergence[10] while the online approximation of BFGS (O-BFGS) is not necessarily convergent.[11]
Notable open source implementations include:
optim general-purpose optimizer routine uses the L-BFGS-B method.Optim.jl also implements the L-BFGS and L-BFGS-B algorithm.[12]
Notable non open source implementations include: