simkit.solvers.gradient_descent#
Functions#
|
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 thantoleranceormax_iteris reached.- Parameters:
x0 ((n, 1) np.ndarray) – Initial guess.
energy_func (callable) – Maps
xto a scalar energy. Only used whendo_line_searchis True.gradient_func (callable) – Maps
xto the gradientg.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_searchis 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_infois True.