Week_2 Assigment issue

After getting correct answer of
Gradient at initial w, b (zeros): -65.32884974555672 -5.83913505154639
Using X with shape (4, 1)

Still I am getting error like - AssertionError: Case 1: dj_db is wrong: -0.5 != 0.0

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)
50 dj_dw, dj_db = target(x, y, initial_w, initial_b)
51 #assert dj_dw.shape == initial_w.shape, f"Wrong shape for dj_dw. {dj_dw} != {initial_w.shape}"
—> 52 assert dj_db == 0.0, f"Case 1: dj_db is wrong: {dj_db} != 0.0"
53 assert np.allclose(dj_dw, 0), f"Case 1: dj_dw is wrong: {dj_dw} != [[0.0]]"
54

AssertionError: Case 1: dj_db is wrong: -0.5 != 0.0

What will be the issue in code.
Please let me know, I am stuck here for finishing this asingment.

Regards

Rahul

Hi Ruhul,

Assume

x = np.array([2, 6,]).T
y = np.array([4.5, 12.5,]).T
initial_w = 2.
initial_b = 0.5

Since w \times x + b - y is zero for all samples, the errors are zero, your dj_db in this case should become zero. Please check if your implementation is able to deliver zero dj_db, if not, something is wrong in your code and you need to figure it out.

1 Like

hi sir

thank you for suggestion, now I passed my week 2 assigment .

Regards
Rahul

1 Like

You are welcome Rahul!