simkit.solvers.gradient_descent#

Functions#

gradient_descent(x0, energy_func, gradient_func[, ...])

Gradient descent for minimizing a scalar energy.

Module Contents#

simkit.solvers.gradient_descent.gradient_descent(x0, energy_func, gradient_func, tolerance=1e-06, max_iter=1, do_line_search=True, step_size=1.0, return_info=False)#

Gradient descent for minimizing a scalar energy.

At each iteration we step along the negative gradient, using either a backtracking line search or a fixed step_size, until the step is smaller than tolerance or max_iter is reached.

Parameters:
  • x0 ((n, 1) np.ndarray) – Initial guess.

  • energy_func (callable) – Maps x to a scalar energy. Only used when do_line_search is True.

  • gradient_func (callable) – Maps x to the gradient g.

  • tolerance (float) – Convergence tolerance on the norm of the step alpha * dx.

  • max_iter (int) – Maximum number of iterations.

  • do_line_search (bool) – If True, run a backtracking line search to pick the step size, otherwise use step_size.

  • step_size (float) – Fixed step size used when do_line_search is False.

  • return_info (bool) – If True, also return a dict with per-iteration diagnostics.

Returns:

  • x ((n, 1) np.ndarray) – Minimizer estimate.

  • info (dict, optional) – Returned only when return_info is True.