#C2W4 Why this error?

Your gradient_check_n() function has an error. It doesn’t return the correct results for one of the tests that are in gradient_check_n_test_case().

You can find this test function in one of the .py files that are imported in Cell 1 in the notebook. These files can be inspected via the File menu.

Getting 1.0 as the answer most likely means you’ve made a mistake in the final difference calculation. Please carefully examine the math formula there and then compare that to your code. One other thing to check is to note that grad and gradapprox in that formula are vectors, not individual elements of vectors, right?

1 Like

Sir I examined my difference code against the mathematical formula but still I have the error. what should i do next?

One common mistake is student copy code from theta_plus[i] and paste it to theta_minus[i] without changing the sign.

It’s probably time to just look at your code. Please see your DMs for a message from me about how to proceed with that.

To close the loop on the public thread, the error is a classic “copy/paste” error. The theta_minus code was copied from the theta_plus, but not changed. So gradapprox ends up as all zeros, which is why the difference value ends up as 1.0.