WRITE · TRACE · UNDERSTAND

Numerical Gradient Check

Compare a supplied gradient with central finite differences.

Your experiment

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

Python runs in your browser. Your draft stays on this device.

What to look for

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.

Watch your code work

Ready to experiment

Write a solution or load the worked answer, then choose Trace & check.

Step through arrays, variables and training curves produced by your own Python.