Skip to main content

gradient_descent

Function gradient_descent 

Source
pub fn gradient_descent(
    f: impl Fn(&[f64]) -> f64,
    grad: impl Fn(&[f64]) -> Vec<f64>,
    x0: Vec<f64>,
    lr: f64,
    tol: f64,
    max_iter: u32,
) -> OptResult
Expand description

Gradient descent with fixed learning rate.

Minimises f starting from x0 using the gradient grad. Stops when the L2 norm of the gradient is below tol.