C1_W2_Linear_Regression

Using X with shape (4, 1)

ValueError 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

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

not getting why this error is occurred

Please help

Hi @Rama_Sikarwar,

You have correctly used y[i] to retrieve the i-th label, and you need to do the same for all the x as well.

Raymond

P.S. we don’t encourage learners to share assignment code, so I removed it. Let me know if you can fix the problem.