Week 3 practice lab: logistic regression Wrong value

dj_db at test w and b: 0.005
dj_dw at test w and b: [0.17311829812258483, 0.390123464076812]

AssertionError 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)
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}"
54 assert dj_dw.shape == test_w.shape, f"Wrong shape for dj_dw. Expected: {test_w.shape} got: {dj_dw.shape}"
55 assert np.allclose(dj_dw, [-0.11999166, 0.41498775, -0.71968405]), f"Wrong values for dj_dw. Got: {dj_dw}"

AssertionError: Wrong value for dj_db. Expected: 0.28936094 got: -0.07142857142857142

Now I’m solving Excercise3 so That like error occur… I can’t solve that …:joy:
Can you help me ?

Hi @qkqk1009

It looks like your code didn’t pass the first test when w is initialised to zero. Please use the hints provided and follow it step by step to get the logic right. Also, remember that Python uses indentation for code blocking. If your line of code is outside of a code block, then the logic will be wrong and resulted in incorrect output.

I didn’t find the solution.
The code above was correct.
I wrote code again, I was concerend about block… but I can’t…
Can you help me ?

Hi @qkqk1009

The part of code for calculating f_wb is incomplete. Your code initialised z_wb = 0, but there is no calculation after that. Passing 0 value to the sigmoid() is not going to return any useful values. Please check the Hints provided for a step by step guide on how to calculate f_wb.

Hi @Kic
I understand your explain so I’ll try to solve the code.
Thanks you so much Kic :grinning: