C1_W2_Linear_Regression all test passed but getting Code Cell UNQ_C1: Function 'compute_cost' is incorrect. Check implementation. Code Cell UNQ_C2: Function 'compute_gradient' is incorrect

All test passed but still getting error like “Code Cell UNQ_C1: Function ‘compute_cost’ is incorrect. Check implementation.
Code Cell UNQ_C2: Function ‘compute_gradient’ is incorrect. Check implementation.
If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.
This dependency may be the cause of the errors.”

Hello @rahul_kumar_singh ,

Please review general instructions below

Important Note on Submission to the AutoGrader

Before submitting your assignment to the AutoGrader, please make sure you are not doing the following:

  1. You have not added any extra print statement(s) in the assignment.
  2. You have not added any extra code cell(s) in the assignment.
  3. You have not changed any of the function parameters.
  4. You are not using any global variables inside your graded exercises. Unless specifically instructed to do so, please refrain from it and use the local variables instead.
  5. You are not changing the assignment code where it is not required, like creating extra variables.

Finally, try to reset your workspace and rerun the code.

Thanks,
Mo

1 Like

Also, check that you have not renamed your notebook. The grader only looks at the notebook that has the original file name.

hi @Mo_Okasha,

checked all the 5 point and refresh the code also the file name , still getting same message,

** removed new variable , added just below code all tests are passed
compute_cost:
for i in range(m):
total_cost += ((wx[i]+b)- y[i])**2
total_cost = total_cost/(2
m)

compute_gradient:

for i in range(m):
   dj_db += (w*x[i]+b) - y[i]
      dj_dw += ((w*x[i]+b) - y[i])*x[i]
dj_dw /= m
dj_db /= m

Hello @rahul_kumar_singh ,

Refreshing the code is not enough. We need to reset the workspace:

from the menu bar at the top:

Kernel → Restart and Clear Output
Cell → Run All

And see if that helps. If that doesn’t help, then try “Help (very top right of the screen) → Lab Help → Reboot Server” and then run the cells again.

Let us know if neither of those things fixes the issue.

Thanks

restarted kernel → run All the cells Still facing same

issue resolved…

issue was with my organization laptop, save/Autosave is disable

Completed assignment :smile:

how did you enabled Autosave?

I’m having the same problem as yours and my autosave seems to be disabled as well, but I don’t know how to enable it.

You don’t have to enable it. It just doesn’t work very quickly.
Always save your work by clicking on the Save button.

if by Save button you mean the Save and Checkpoint button, it’s not working as well. I also tried pressing Save As and I get “error”. By the left side of the box written Trusted it’s also written “error”. I press on it and it vanishes, but comes back later. There’s no error pointed in any of my notebook cells.

That’s very odd. I have not heard of that issue before.
Is your course subscription still valid?

Are you working in the Coursera Labs environment?

His codes are incorrect. He hard-coded cost and parameters.

How does that relate to the issue of the Save button not working?

I replied based on the his first message in this post.

I see. The “autosave not working” issue is a red herring.
Thanks for the clarification.

I found a link related to your issue, try to clear your cache history and then work on your notebook. See if it work then (note I am not sure if this is for Coursera but for people who are jupyter notebook on their local system) but you can give it try

It also mentions autosave only doesn’t work if your notebook has not loaded properly as there can be any network issue or any. So make sure whenever you face such issue, always refresh your work environment or update your notebook.

Hope it helps!!!

Regards
DP