PythiloLesson 7 of 12 · progress kept in this browser

Numerical Gradient Check

Compare a supplied gradient with central finite differences. A deliberately wrong derivative must produce a visible error, rather than passing because training loss happens to fall.

x, epsilon = 2.0, 0.001
f = lambda value: value**3 - 2*value
print((f(x+epsilon)-f(x-epsilon))/(2*epsilon))
Your task

gradient_error(x, epsilon, derivative) returns abs(derivative - numerical_gradient) for f(x)=x**3-2*x. Use the central difference; epsilon > 0.