MLS Lab assignment C1_W3_Logistic_Regression

Hi,
in UNQ-C3 Gradient for logistic regression I got the expected results, however when I run the precompiled code of # Compute and display cost and gradient with non-zero w I get slightly different values in the decimal numbers.
How is it possible if the previous results were correct?
In the following picture you can see what I mean


Moreover, I can see that by changing indentation to the code, the results change.

I would appreciate any help since I cannot proceed in the Lab exercises.
Thank you

Hi @Manila ,

The compute_gradient_test() has different set of data. You can take a look of the file by clicking the file tab->open->public_tests.py.
In python, the indentation is the syntax for code block structure. You need to check if the logic is still correct by moving the indentation.

Hi,
thank you for the attention.
Actually, I don’t know how to proceed. I took a look at public_tests file but I cannot understand how to fix the problem.
Could you please give me any other tips?
Thanks.

Hi @Manila ,

I was highlighting there are more than one test for testing that function. The problem is in your code for the compute_gradient(). If you followed the hints, it should give you the step by step guide on how to code that function. Just make sure the code block is structured correctly so that the logic is followed properly. Also, do refresh the kernel and rerun the code.
If you are still unable to solve the problem, then send me a DM with the code for that function, and I will have a look for you.

2 Likes

Thank you Kic! I solved the problem.