Not able to identify bug in week 3 assignment, (mls course 1)

I have tried for 4 weeks!!! to fix the bug - not getting the expected output - due to which I’d to pay again to finish this assignment. I hope someone can help. My codes " dj/dw" are spitting the expected values to qualify for Compute gradient test

Hi @Rohit_Venugopal1 ,

Did you code pass the test for w being initialised to zero?
Your dj_dw output contains 3 elements which is exactly the same. How could that comes about? Check the hints on how dj_dw should be calculated.

Yes it did, still pls check and let me know if it didn’t

well my dj_dw are coming to be same though I have followed the hints precisely. I can’t figure how’s that happening?

Hi @Rohit_Venugopal1 ,

The reason why all 3 elements of your dj_dw are the same is because only the gradient of the last attribute of example i is added to dj_dw. If you check against the hints, you would see the difference in the ‘for’ loop for calculating the dj_dw.

No, your dJ_dw values are not correct:

Can you elaborate please! I checked, I don’t see anything wrong with my indentations in my code. For reference I have pasted an image of my code besides image of hints in the image below
{code removed by mentor}

Hi @Rohit_Venugopal1,

Take a closer look at the second half of the hint and compare that with your code. I hope this helps you solve the problem.

Hint

You need to add each example’s calculated gradient of the cost function to a corresponding place in the array for gradient weight parameters right after you calculate the jth gradient in the “for loop” to get dj_dw for each attribute.

Ah I got my mistake, I didn’t add the element subscript for dj_dw.

Thank you so much, for clarifying my doubt.