C1_W3_Logistic_Regression compute_gradient Assertion Error

Hi,

I am new to Machine Learning and got stuck at the Week 3 assignment on compute_gradient function. Here is the error message.

Can anyone please help?

Thanks in advance,

Jing

Hi @Jing_Chen ,

It could be the the bias term is added within the 2nd ‘for’ statement, so please make sure it is outside of that ‘for’ statement. Because, the 2nd ‘for’ statement is to loop through all the features of one sample. The bias term should only be added after that.
In Python, indentation is used to structure code block. Incorrect indentation would bring about the wrong logic to the code.
Also, double check your code against the Hints to ensure the logic is correct

Hi Kic,

You are spot-on. The issue is fixed now. Thanks very much. Have a great day!

Best,

Jing

Hi Kic,

Do you mind sharing what information in the trace led to your suggestions?

Thanks,

Jing