Continuing the discussion from Compute_gradient_test(compute_gradient):

*{Moderator Edit: Solution Code Removed}*

# Compute and display cost and gradient with non-zero w and b

test_w = np.array([ 0.2, -0.5])

test_b = -24

dj_db, dj_dw = compute_gradient(X_train, y_train, test_w, test_b)

print(‘dj_db at test w and b:’, dj_db)

print(‘dj_dw at test w and b:’, dj_dw.tolist())

# UNIT TESTS

compute_gradient_test(compute_gradient)

## and I am getting this error :

dj_db at test w and b: -0.5999999999991071

dj_dw at test w and b: [-44.831353617873795, -44.37384124953978]

ValueError Traceback (most recent call last)

in

8

9 # UNIT TESTS

—> 10 compute_gradient_test(compute_gradient)

~/work/public_tests.py in compute_gradient_test(target)

49 test_w = np.array([1, 0.5, -0.35])

50 test_b = 1.7

—> 51 dj_db, dj_dw = target(X, y, test_w, test_b)

52

53 assert np.isclose(dj_db, 0.28936094), f"Wrong value for dj_db. Expected: {0.28936094} got: {dj_db}"

in compute_gradient(X_train, y_train, test_w, test_b, *argv)

25 test_b = -24

26 for i in range(m):

—> 27 z = np.dot(X_train[i],test_w) + test_b

28 f_wb_i = sigmoid(z)

29 err_i = f_wb_i - y_train[i]

<**array_function** internals> in dot(*args, **kwargs)

ValueError: shapes (3,) and (2,) not aligned: 3 (dim 0) != 2 (dim 0)