C1_W2_Linear_Regression- error

Like this

Thank you very Deepti … I really appreciate your help … Thanks a lot

So you passed the grader cell? Just let me know once issue is solved.

Just another request, from next time you have any issue regarding any assignment try to create a new post by choosing the appropriate specialisation, course, week and assignment name. So you get better reply from all the mentors. By posting questions and issue in order post, sometimes it can confuse the person trying to solve the issue. Like here you posted week 2 assignment in week 1 assignment topic.

I understand you are newcomer, so just guiding you right way.

Keep Learning!!!


Okay, sure yes… the issue is resolved and i am kind of facing this in all my assignments … I will rework on it and will post on relavent post only … Thank. you for your support

Happy to help!!!

Just heads up, all learners go through these issues, what you were facing issue other have to, try search with the right statement like in your case you could type in search Check implementation MLS Course 1 week 2 assignment compute cost in search bar. that would lead you to find solution post were many have already face similar issues and got the solution, otherwise make a new post.

Have a good day!!!


I am facing the same issues. Inspite of entering all the code correctly and not getting any error too, but after submitting I am getting error as -. Please help. I have been thorugh this code like more than 10 times , not sure what to do now :frowning:

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 Swastee,

No problem. happy to help. Can you please tell if you have not changed anything to the template code given at the time of uploading the notebook.

Did you refer to the hints given below the grader cells for both the grader cell?

If yes and still facing this issue, then share your notebook via personal DM. Click on my name and then message.

Also it is better to create new post when you have such issue. You can always tag the person you want to look for. As this post header mentions Week 2 assignment, but then in selection it shows week 1 assignment.

These confusion will delay response from any mentor to help


Thanks Deepti for agreeing to help me. I have messaged you via DM. Please check.

Hello Swastee,

UNQ C1 error:
Can I know why have you recalled cost_sum=0 outside the ###START CODE HERE and ###END CODE HERE

Refer this image to do correction accordingly

Error 2: Seems like you changed/ or alter the template code for compute_gradient cell.
See this image

Do the correction for this based on the below image



I have tried both , still getting the error. have DM you the code. Please have a look.

Hello Swastee,

You are still adding code lines to your template code lines.

I am repeating again, you are only suppose to replace the code with the right codes and do not add any extra code line as the grader wants you to write the code based on the template code given.

I have already shared how the template codes looks for compute_gradient in previous comment.

Sharing here template code for compute cost

if you notice in the compute cost grader cell, your code has cost = and the template code which I have shared has cost += (so you do not require to hard code your cost code by recalling again with cost_sum as per the template code).

In the compute gradient grader cell, again as I mentioned in the previous comment that you are suppose to use only the template code, you still didn’t do any change to that grader cell

Template code for compute gradient

as per the hint screenshot explained in previous comment

you need to write dj_db += and dj_db += based on the hint in one code line without adding any extra codes.
So think if dj_db_i = f_wb - y[I] and dj_db += dj_db_i is this, how will you write dj_db in a single code line. It is actually pretty straight forward but what you have done because of hints you added those extra line.

Same goes for dj_dw.
if dj_dw_i = (f_wb) - y[I]) * x[I] and dj_dw += dj_dw_i is this, how will you write dj_dw in single code line.

Please do these corrections. Once you pass the test let me know.


Hello Swastee,

Review your updated codes again with the images I have shared.

You creating more and more errors while doing the corrections.

  1. You are creating an indentation error with f_wb (is red in color but should be green in color if placed at the right place) in compute cost grader cell.

  2. In the cost code line again there is type error.

  3. if dj_db_i = f_wb - y[i] and dj_db += dj_db_i is this,
    how is dj_db = (w * x[i] + b) - y[i]???
    dj_db += will be what dj_db_i right? and what is dj_db_i from the above statement?write the same code what is mentioned for dj_db_i??
    I am not suppose give straightforward codes. if you read the above sentence you will understand dj_db += is nothing but what is mentioned for dj_db_i!!!

  4. same goes for dj_dw +=

Hi team
I attempted to submit my assignment but it is shown the below error although the all cells ran and passed:
Cell #3. Can’t compile the student’s code. Error: OSError(‘data/ex1data1.txt not found.’)
I can open file ex1data1.txt from the data folder and the load_data function from the utils.py file.
Could someone shed light on how to fix the error?
many thanks
Christina Fan

any tip for the exercise because the code doesn’t work ?


this error means one of file related to assignment is not found, by any chance you deleted any files for the assignment you are doing. This can also happen if any of the cells was deleted from the assignment folder.

If you have not deleted. then what you could do, get a fresh copy of the assignment and re-do the assignment.

Click file ===delete the assignment file, you will find a 404 error on screen. At this time, click Help then reboot.
Once rebooting is done, click help again, then Update Lab and then Get the Latest Version.

Make sure you have saved a copy of the assignment you did previously for comparison.

Let me know once your issue is resolved.


Kindly create a new post the issue you are encoutering with an image if encountering any error.

Do not share any codes on your post thread as it is against community guidelines.

Hi DP,
Thank you so much for your prompt response.
Sorry I couldn’t find delete the assignment file option from File menu. (also I’m unsure what did you mean by click file ====delete the assignment file)
The error says OSError(‘data/ex1data1.txt not found.’) Yet I can ran the cell 3 and output the data, so it didn’t make sense if ‘data/ex1data1.txt not found.

could you please provide more information on how to delete the assignment file?

Please note i did try reboot and got the latest version lab, yet same error occurred.

Many thanks

When click file you will find an option which will show you all the necessary files required to do file with your assignment.

Can you see that page?

I got it DP. Thank you and it now passed 100%. Greatly appreciated your assistance!

Happy to Help Christina.

Keep Learning!!!