Expand description
Forward-difference gradients and gradient checking (SciPy’s optimize.approx_fprime and
optimize.check_grad).
See the book entry Brute force, isotonic regression and gradient checks.
Functions§
- approx_
fprime - The forward-difference gradient
(f(x + hεᵢ) − f(x))/hoffatx(SciPy’sapprox_fprime), with stepepsilon(SciPy’s default is√ε ≈ 1.49·10⁻⁸); the step actually used is the representable(xᵢ + h) − xᵢ. Its error is abouth|f''|/2 + 2ε|f|/h, smallest near the default. - check_
grad - The Euclidean norm of the difference between an analytic gradient
grad(x)and the forward-difference gradient off(SciPy’scheck_grad): about√εtimes the size of the second derivatives whengradis right, of the order of the gradient itself when it is wrong.