How can finite differences check gradients?
Reveal the answer and explore the explanation.
10HardHow can finite differences check gradients?
Answer
Hard
How can finite differences check gradients?
Answer
Approximates derivatives using changes in function values at nearby inputs.
Practical example
Numerically check an analytical gradient using small perturbations.
PythonRelated concept example
def f(x): return x*x
x, h = 3.0, 1e-5
print((f(x+h)-f(x-h))/(2*h))Central finite differences approximate the derivative 2x.
Reference: Further reading ↗