C1_W3_Logistic_Regression assignment compute cost error

Hello,

I am having trouble with the compute_cost function when I run the test with 0’s i get this output;

Cost at initial w and b (zeros): 1.386

Expected:
Cost at initial w and b (zeros) 0.693

This is throwing off the calculation somewhere I’ve copied the code from the hint section but it’s still not working.

Here’s the lab session;
jadqsddtrxep

1 Like

Your lab session does not help, no one but the course staff can see your submission data.

Hint:
When the weights are zeros, then the sigmoid of z will always be sigmoid(0) = 0.5. It’s the same value for both the true and false cases. When you do the math to compute the cost, that will give a value of 0.693 (because that’s the natural log of 0.5).

2 Likes

Note also the following mathematical relationship:

0.693 * 2 = 1.386

Are you sure that your code faithfully implements the mathematical formula for the cost? The above relationship seems like a clue about the nature of the problem. :nerd_face:

2 Likes

my indentation was off which doubled the first “for” loop. thanks all.

1 Like