tfp.optimizer.lbfgs_minimize( value_and_gradients_function, initial_position, num_correction_pairs=10, tolerance=1e-08, x_tolerance=0, f_relative_tolerance=0, initial_inverse_hessian_estimate=None, max_iterations=50, parallel_iterations=1, name=None )
Applies the L-BFGS algorithm to minimize a differentiable function.
Performs unconstrained minimization of a differentiable function using the L-BFGS scheme. See [Nocedal and Wright(2006)] for details of the algorithm.
The following example demonstrates the L-BFGS optimizer attempting to find the minimum for a simple high-dimensional quadratic objective function.
# A high-dimensional quadratic bowl. ndims = 60 minimum = np.ones([ndims], dtype='float64') scales = np.arange(ndims, dtype='float64') + 1.0 # The objective function and the gradient. def quadratic(x): value = tf.reduce_sum(scales * (x - minimum) ** 2) return value, tf.gradients(value, x) start = np.arange(ndims, 0, -1, dtype='float64') optim_results = tfp.optimizer.lbfgs_minimize( quadratic, initial_position=start, num_correction_pairs=10, tolerance=1e-8) with tf.Session() as session: results = session.run(optim_results) # Check that the search converged assert(results.converged) # Check that the argmin is close to the actual value. np.testing.assert_allclose(results.position, minimum)
 Jorge Nocedal, Stephen Wright. Numerical Optimization. Springer Series in Operations Research. pp 176-180. 2006
value_and_gradients_function: A Python callable that accepts a point as a real
Tensorand returns a tuple of
Tensors of real dtype containing the value of the function and its gradient at that point. The function to be minimized. The first component of the return value should be a real scalar
Tensor. The second component (the gradient) should have the same shape as the input value to the function.
Tensorof real dtype. The starting point of the search procedure. Should be a point at which the function value and the gradient norm are finite.
num_correction_pairs: Positive integer. Specifies the maximum number of (position_delta, gradient_delta) correction pairs to keep as implicit approximation of the Hessian matrix.
Tensorof real dtype. Specifies the gradient tolerance for the procedure. If the supremum norm of the gradient vector is below this number, the algorithm is stopped.
Tensorof real dtype. If the absolute change in the position between one iteration and the next is smaller than this number, the algorithm is stopped.
Tensorof real dtype. If the relative change in the objective value between one iteration and the next is smaller than this value, the algorithm is stopped.
initial_inverse_hessian_estimate: None. Option currently not supported.
max_iterations: Scalar positive int32
Tensor. The maximum number of iterations for BFGS updates.
parallel_iterations: Positive integer. The number of iterations allowed to run in parallel.
name: (Optional) Python str. The name prefixed to the ops created by this function. If not supplied, the default name 'minimize' is used.
optimizer_results: A namedtuple containing the following items:
converged: Scalar boolean tensor indicating whether the minimum was found within tolerance.
failed: Scalar boolean tensor indicating whether a line search step failed to find a suitable step size satisfying Wolfe conditions. In the absence of any constraints on the number of objective evaluations permitted, this value will be the complement of
converged. However, if there is a constraint and the search stopped due to available evaluations being exhausted, both
convergedwill be simultaneously False.
num_objective_evaluations: The total number of objective evaluations performed.
position: A tensor containing the last argument value found during the search. If the search converged, then this value is the argmin of the objective function.
objective_value: A tensor containing the value of the objective function at the
position. If the search converged, then this is the (local) minimum of the objective function.
objective_gradient: A tensor containing the gradient of the objective function at the
position. If the search converged the max-norm of this tensor should be below the tolerance.
position_deltas: A tensor encoding information about the latest changes in
positionduring the algorithm execution.
gradient_deltas: A tensor encoding information about the latest changes in
objective_gradientduring the algorithm execution.