Week1: Gradient Checking

Hi Everyone,

I have the same issue

What you see in the printed lines is:
print(theta_plus, theta_minus, J_plus, J_minus, gradapprox)
print(grad)
print(numerator)
print(denominator)

At that point, all the previous tests had passed

Best regards

Well, if the previous tests are good, then your gradient_check logic must be wrong. Here’s what I get with my passing code and your print statements:

4.0000001 3.9999999 8.0000002 7.9999998 2.0000000011677344
2
1.167734353657579e-09
4.000000001167734
Your backward propagation works perfectly fine! difference = 2.919335883291695e-10

Looks like you need to check your logic for computing gradapprox. :nerd_face:

The differencewe have is in gradapprox …

I can’t get it … it’s just simply gradapprox = (theta_plus - theta_minus) / (2.*epsilon)

I wasn’t my logic. It’s a typo in the instructions

I just left epsilon (not 2 * epsilon) as denominator a it worked just fine

Who should I contact to so that this can be ammended on the notebook?

I think you must be mistaken somehow. I did not have this problem.

As Paul pointed out, you did not implement function correctly.

From your post,

gradapprox = (theta_plus - theta_minus) / (epsilon) =
((theta + epsilon) - (theta - epsilon))/epsilon = 2*epsilon/epsion = 2

Your gradapprox is always 2. For this exercise, accidentally, gradapprox =2. So, it can be seen that you passed this test, but actually, not.

Please revisit your implementation. You mixed up theta and J.

Yes, you’re right … and it happened to me in the next functions down the notebook. Thanks for pointing me out my typo …

FYI @paulinpaloalto

Best regards both of you