Week2 Practice Lab - Gradient calculation

I am apparently not finding any problem with the calculation of the gradient, but I am getting the following error, please advise.

Gradient at initial w, b (zeros): -0.04747762052631062 -0.007323908939747608
Using X with shape (4, 1)

AssertionError Traceback (most recent call last)
in
6 print(‘Gradient at initial w, b (zeros):’, tmp_dj_dw, tmp_dj_db)
7
----> 8 compute_gradient_test(compute_gradient)

~/work/public_tests.py in compute_gradient_test(target)
60 dj_dw, dj_db = target(x, y, initial_w, initial_b)
61 #assert dj_dw.shape == initial_w.shape, f"Wrong shape for dj_dw. {dj_dw} != {initial_w.shape}"
—> 62 assert dj_db == -2, f"Case 1: dj_db is wrong: {dj_db} != -2"
63 assert np.allclose(dj_dw, -10.0), f"Case 1: dj_dw is wrong: {dj_dw} != -10.0"
64

AssertionError: Case 1: dj_db is wrong: -0.6640625 != -2

There appears to be an error with your calculation of the gradient of the bias (dj_db).

Could you please have a look and give some hints on the error that you mentioned here.

I have solved it. The assignment has been submitted.

Hello, I am getting this same error you replied too and I have read all of the older posts like this one. I haven’t been able to solve the dj_db problem. Could you please help?

It’s very brave of you to add a reply to a thread that has been cold for three years. :grinning_face:

= = = =

I presume when you say you have the same error, it’s that the dj_db value is incorrect.

What would you say is your level of Python skill and experience? I need to know that to give you useful advice.

The most common error in this assignment is using incorrect indentation. That’s how Python defines blocks of code.

So, check carefully that you have all of the indentation correct.

After you check that, please report back, and we can take the debugging a step further.

Hi there, yes, I’ve been stuck with this problem and when I read the exact same output… I took a shot. Thank you for responding so quickly. I went back to look at my indentation but now I can’t run anything more. The run icons disappeared for each cell. I submitted once but I thought we could submit multiple times. As far as Python, I am a true beginner. I was working in Java before now. Also, a “warning” icon as popped up next to the assignment and I am not sure what that means either. Thank you for your time.

TMosh,
I continued to work on it and it turned out to be the indentation error you mentioned and my issue is resolved. This is something I will have to get used to with Python. However, I want to thank you again for the suggestions and quick response to my question. I really appreciate all your help. Thank you so much.

Nice work!

Likely the kernel burped and needed to time-out and restart.

You can submit your work as many times as you like.