Week 3 practice lab: logistic regression Exercise 3

In the 3rd exercise (gradient descent) my value for dj_db at initial w and b (zeros) does match the expected output but my dj_dw at initial w and b does not. In the hints I checked my code and everything seems to be correct. What could be wrong?

This is my code:

# mentor edit: code removed

Please do not post your code on the forum. That’s not allowed by the Code of Conduct.

I have edited your message to remove the code.

The best course of action is to describe the situation, and post a screen capture image of your test results, or any error messages that the notebook generates.

If a mentor needs to see your code, we’ll contact you with instructions.

Tip: The bias value ‘b’ should only be added once - not inside your loop over the features.

Tip2: Check your indentation, some of the columns don’t line up correctly.

1 Like

Even when I put the b value outside the loop and check any indentation, the outcome stays the same.
dj_db at initial w and b (zeros):-0.1
dj_dw at initial w and b (zeros):[-0.3738794650046383, -0.4476490644756638]

After you modified the code, did you re-“Run” the code in that cell?

Changes aren’t automatically compiled, you have to run the cell again whenever you modify it.

The only other reason that moving the summation with ‘b’ could not have any impact is if the test you’re running sets b = 0.

Hi, yes I did rerun the code, and nowhere am I setting b = 0.
I have no clue why the values are off.

(edited to remove code markup}
Verify whether the code for dJ_dw[j] is doing a summation (+=) , vs. doing an assignment (=).

1 Like