C1_W3_Logistic_Regression - Exercise 2

In Exercise 2 we define the compute_cost function. My code works correctly for first test case (“Cost at initial w and b (zeros): 0.693”), but produces the incorrect answer for the “non-zero w and b” test case. The information in the error doesn’t point me towards the source of the problem. Am I missing something?


AssertionError Traceback (most recent call last)
in
8
9 # UNIT TESTS
—> 10 compute_cost_test(compute_cost)

~/work/public_tests.py in compute_cost_test(target)
24 b = 0
25 result = target(X, y, w, b)
—> 26 assert np.isclose(result, 2.15510667), f"Wrong output. Expected: {2.15510667} got: {result}"
27
28 X = np.random.randn(4, 3)

AssertionError: Wrong output. Expected: 2.15510667 got: 2.75932426268233

Make sure you did not include regularization in the compute_cost() function. Your code for that function should not use the lambda_ parameter in any way.

Thank you, Tom. Your comment pointed me to the source of the problem. I edited the code and it now works.

Again, my apologies for circumventing the right process.

David

I’m glad you fixed the issue. Nice work!