C1 W3 Logistic Regression - AssertionError (Compute cost)

Good day fellow leaners!

Trying to figure out my error since 3 days now with regular breaks. Am currenting on C1_W3_Logistic_Regression excercise. I implemented my formular correctly on Compute cost because its displaying correct ouput with zero w, b but when l move downward error persist. If anyone can please assist me?

AssertionError Traceback (most recent call last)
—> 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}"
28 X = np.random.randn(4, 3)

AssertionError: Wrong output. Expected: 2.15510667 got: 1.3862943611198908

my compute cost is below checked all indentations:

m, n = X.shape

{Moderator Edit: Code Removed}

return total_cost

#for compute with zero result:

Cost at initial w and b (zeros): 0.693

Expected Output:

Cost at initial w and b (zeros) 0.693

Hi @Abiton_Padera ,

Passing a single test case doesn’t guarantee that it will pass all the later test cases unless your code is correct.

In your code, It should be z_wb += z_wb_ij, not z_wj += z_wb_ij because z_wj initializes to 0 at every iteration, so it wouldn’t make sense to add z_wb_ij to it.

Also, please note that posting code here is not allowed.

Hi @Abiton_Padera! Please note that posting your code is not allowed. I deleted it but next time, avoid posting your code. You just need to share your error and if mentors need to see your code, they will ask you to send them privately.


thank you so much,
It is my first interaction with the community. I have taken note.

kind regards


hi @Mujassim_Jamal

Thank you for your response, my first with the community. I feel welcome. and will also check my code as your advice.

kind regards

Hi, I am having a issue with this exercise too.

I cannot find the error in my compute_cost function. Could i share my code with a mentor privately to help?


Hi bud,
l am willing to help. Can you share more details? l can see where you are missing.

kind regards