QUESTION 10 OF 10

How can finite differences check gradients?

Reveal the answer and explore the explanation.

10
Hard

How can finite differences check gradients?

Answer
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 ↗

Last 30 min revisionHigh-yield interview Q&As