Lab 4 numpy error


Can I know is this assignment from Week 1?

as your assignment name in the screenshot shows untitled2? and there is no assignment for week 1 but for week 2 it is there with name linear regression.

Based on your error log, you have changed the template code by adding codes separately for dj_dw_i and dj_db_i which was not required.

The template looks like this

Do the correction accordingly and pass the test.


YES!! ITS from Week 1. And I just wrote as it is that it was in Lab 4 Gradient descent.
Shall I continue this work in the previous program?
Thank You

Week 1 doesn’t have any practice assignments. Week 2 has assignment and my reply is related to that. kindly make sure you are referring to the same assignment I have shared the screenshot with assignment name mentioned.

I am so confused. Am I working in a course lab environment? Would you tell me the steps? I had seen a reply that suggested a method to work in a course environment, but I can’t find it now. Maybe that is why I am having a problem.

Hello teniza,

Based on your screenshot you are working on Coursera.

The only confusion from your screenshot is the title which can happen either if you have had made a copy of the assignment as I can see you have opened multiple pages for the same assignment :slight_smile:

You can clear your confusion by click on file and then open where the assignment names will be mentioned and also the copy of the assignment which in your case is named as Untitled2

What steps you need help in regards to this?

The only mistake or incorrect code with the screenshot you have shared is those two extra code line dj_dw_i and dj_db_i which needs to go to the dj_dw += and dj_db += for correcting the codes.

If you still have any questions especially sharing the codes, please share via personal DM.

Screenshot of any error you can share here.


Hello all,

It appears to be the optional lab for Gradient Descent. However, @teniza_bhujel might somehow have changed the name of the notebook to “Untitled2”.

From the traceback, there is the problem:

@teniza_bhujel might again have somehow changed y[i] into y(i) and that caused the error because y is a numpy.ndarray object and the parenthesis made it a call. Changing it back to square brackets will solve the problem.

@teniza_bhujel, you are not asked to change any code for running an optional lab, but I agree that it is sometimes useful to experiment, so be careful when editing the code, but if you think you have not edited anything and want to have the original lab notebook back, you may check out B5 of the MLS FAQ for further instructions.


1 Like

Thanks Raymond, for checking that, I missed the browser part where it explained optional lab.

You are welcome, @Deepti_Prasad :wink:

Just one more comment for @teniza_bhujel. Cousera relies on the correct name to open a lab, so if the name is changed to Untitled2, next time you open it Cousera won’t open that one for you, but trying to find the one with the correct name, and if that name doesn’t exist, you will encounter a “404 Not found” error.

The best would be for you to change the name back to C1_W1_Lab04_Gradient_Descent_Soln, or when you see the “404 Not Found” error, click “Help” > “Get Latest Version” > “Update Lab” to get a new copy of the lab. After you get a new copy, you can click “File” > “Open” to access the lab with the changed name.

1 Like

Why is your notebook file named “Untitled”?

Steps I did save and checkpoint the original labwork.
Then I clicked download as Notebook(ipynb)
Then I opened new file to do all those coding to get output, graphs. I thought that is what should be done.

Thank you!! @rmwkwok . Actually, I saved the original lab work and opened a new file to do the same code to see the result. I thought that is what should be done.

You can just edit the original notebook directly - no need to make copies.
In fact, the grader will not grade any notebook but the original filename.

I see, @teniza_bhujel. It depends on what you want to achieve:

  1. The lab you are asking about is not an assignment, but an optional lab. An optional lab does not require you to do any editing, instead, it only asks you to run through all the cells and read through all the text and cell outputs. Therefore, there is no need to make a copy of the file yourself.

  2. From week 2 onwards, you will come across optional labs and assignments. For assignments, If you want to just finish and submit your assignments, then no new file is needed, instead, just work on the original copy provided to you.

  3. For optional lab or assignment, if, for any reason, you want to keep a copy of the original notebook before editing, you still don’t neeed to make a new file yourself, because you can get a refreshed copy anytime by following B5 of the MLS FAQ.

Therefore, there is no need to make any new file yourself.

Have fun with the rest of the course!


Got it!! Thank you all.