Skip to main content

check_grad

Function check_grad 

Source
pub fn check_grad(
    f: impl Fn(&[f64]) -> f64,
    grad: impl Fn(&[f64]) -> Vec<f64>,
    x: &[f64],
    epsilon: f64,
) -> f64
Expand description

The Euclidean norm of the difference between an analytic gradient grad(x) and the forward-difference gradient of f (SciPy’s check_grad): about √ε times the size of the second derivatives when grad is right, of the order of the gradient itself when it is wrong.