C1_W3_Lab09_Regularization_Soln incorrect dj_db

I want to know what is wrong with this code for the function compute_gradient_descent(). It keeps telling me that dj_db is incorrect

Hello @Nada_Selim_Kassem

if you are attempting the Vectorized implementation with the dot product, the 2nd for loop “for j in range(n)” serves no purpose…instead it will keep adding z_wb to itself “n” times (as per your implementation).

Also, when you have “n” features, there will be “n” weight values. So, you need to look at the line
dj_dw = np.sum(dj_dw)/m. Print out dj_dw or dj_dw.shape and see if it matches with your expectation.

Thank you for your quick response, but I still can not get it. I understand that I should not use the vectorized implementation in this code as the given code includes (for loops).
But, I can not figure out what should I write in the z_wb line of code.

It’s perfectly fine if you want to write a vectorized version of the code. The grader won’t care, and the code is much simpler than wrestling with for-loops.

z_wb is the sigmoid of (W dot x[i]) + b.

You already have the (W dot x[i]) part, so you’re mostly done.

Also, please don’t post your code on the forum. That’s not allowed by the Community Standards. Please edit your post to remove the code.


Thank you for letting me know. I deleted it.
I tried vectorized implementation similar to this used in the linear regression assignment.
ValueError: operands could not be broadcast together with shapes (100,) (100,2)
I got this error for the dj_dw line.

This lab (C1_W3_Lab09) does not use the compute_gradient_descent() function.

You do not need to modify any of the code in this lab.

What are you attempting to do exactly?