Why is this the answer?

For the supervised learning course, week 1, in the last programming lab for logistic regression, in the last unit test below, why does the unit test expect 3 values for the weights?

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)

There are multiple test cases there. The one that is directly visible in the notebook has 2 elements in w, and thus in dw. But there must be a test case in public_tests.py/compute_gradient_test that has 3 elements. So why would your code fail in that case? One possible way would be if you referenced global variables in the body of your compute_gradient function.

You can click “File → Open” and then open the file public_tests.py to see what the additional test cases look like.