Course 4 Week 1 Assignment 1: 'conv_forward_test not defined', 'pool_forward_test' is not defined

Course 4 Week 1 Assignment 1:
‘conv_forward_test not defined’, ‘pool_forward_test’ is not defined

I’ve deleted all my Python files, I’ve deleted my ipynb file.
I’ve also tried rebooting the server. I’ve also tried changing the name of the ipynb file.

I’ve already tried refreshing my laptop.(

  1. Rename your existing Jupyter Notebook within the individual notebook view
  2. In the notebook view, add “?forceRefresh=true” to the end of your notebook URL
  3. Reload the screen
  4. You will be directed to your home Learner Workspace where you’ll see both old and new Notebook files.
  5. Your Notebook lesson item will now launch to the fresh notebook.

We are still experiencing problems.

What more can I try?

detail message:
The following cell failed:

A_prev = np.random.randn(2, 5, 7, 4)
W = np.random.randn(3, 3, 4, 8)
b = np.random.randn(1, 1, 1, 8)
hparameters = {"pad" : 1,
               "stride": 2}

Z, cache_conv = conv_forward(A_prev, W, b, hparameters)
print("Z's mean =\n", np.mean(Z))
print("Z[0,2,1] =\n", Z[0, 2, 1])
print("cache_conv[0][1][2][3] =\n", cache_conv[0][1][2][3])


The error was:

NameError                                 Traceback (most recent call last)
<ipython-input-8-182241fd5e53> in <module>
     11 print("cache_conv[0][1][2][3] =\n", cache_conv[0][1][2][3])
---> 13 conv_forward_test(conv_forward)

NameError: name 'conv_forward_test' is not defined

Try to reset the lab entirely, follow these steps:

everything will be reset to its initial state and you can attempt to run the Lab from scratch again!

Thank you for your response.
Unfortunately, that’s how we’ve already tried it.

Right, the error means those tests are not found, usually those tests are in a utils file which you can check by going in File->Open in the Jupyter lab!

I am surprised how come they are not there if you have reset the Lab. Make sure that the file is there by going there and see inside the file, those functions-tests are there?

If they are not there, let me know I will tag someone from the QA team to have a look at it because I don’t have access to this course myself!

If you are running the labs locally (which is not recommended BTW), then you need to download all the files, not just the notebook. There is a topic about that on the DLS FAQ Thread.

If you have this problem on the course website, then it just means you did not run all the previous cells in the notebook. You need to do that everytime you open or restart the notebook. Click “Cell → Run All Above” and then run your test cell again. Notice that the “import” commands happen in the very first executable cell early in the notebook. The tests are imported from the file

Also note that you filed this question under a generic category, but we can see by looking at the content that you are talking about DLS C4 W1 A1. I moved the thread for you by using the little “edit pencil” on the title. You’ll have better luck getting timely answers if you file your threads in an appropriate category, so that you get the attention of people who are familiar with the course you are working on. There are lots of different courses here now and more being added all the time, so it’s sometimes hard to tell what someone is asking about.


Thank you for your answer.

“Click “Cell → Run All Above” and then run your test cell again. The tests are imported from the file”

I did it in the above way, Despite proceeding according to the above method, the conv_forward_test function and pool_forward_test function of cannot be called. The same problem as before.

Open the assignment notebook file.
Use “Cell → Restart Kernel & Clear Output.”
Use “Cell → Run All”.

Post back an image of any errors you see.

Thank you for your answer.
I did it as I said, and I attach an error image.

Are you using the Coursera Labs environment?

Yes, I am using the Coursera Labs environment.

Can you post an image that shows the whole Coursera Labs environment while it is showing your error messages?

I’m going off-duty, will be back in about eight hours.

Thank you so much. I attached the overall picture because I thought it would be helpful to be able to see it in its entirety.


The rules do not allow to post code solutions publicly. However, as far as I saw all the tests did pass, you had no errors in these images, what is the issue?

I’m sorry. I didn’t know there was such a rule.
If submit it, i will get 0 points and i will receive a failure result.

Which course and assignment is this exactly, I get different interfaces, I dont know why!

It’s course convolutional neural networks and it’s the first task in week 1.

So it looks like everything runs in the notebook if you just click “Cell → Run All”, but it only fails if you do “Validate” or submit to the grader. I have never seen that situation happen, so I don’t really have a theory other than that there must be something that got changed in the metadata in your notebook that is causing this. One way that could happen is if you downloaded the notebook and worked on it with different tools and then re-uploaded it back to the Coursera website.

One thing to try is to get fresh copies of the notebook and the file. Rename your notebook to save your code and delete the file and all the other “dot py” files that you see in the assignment. Then do the “Get Latest Version” procedure: just click “?” or “Help” in the upper right and then “Get Latest Version” as described on this thread.

Then carefully “copy/paste” over your completed code to the fresh clean copy of the notebook and try again.

Please let us know if that helps or not. If that doesn’t help, then I’m out of ideas and we’ll need to call in the course staff to look.

1 Like

I agree with Paul, most likely the cell in the notebook that imports the unit tests has its metadata modified, such that the grader cannot import it.

Or the cell that calls the unit test had its metadata modified such that is is considered a graded cell. This would cause the grader to run the unit test code (normally it would not do this).

Essentially, the grader usually ignores the unit tests in the notebook, because it provides its own tests. Something about your notebook is defeating the design of the grader.

This can be caused by running the notebook on other platforms than Coursera Labs (for example, VSCode or Colab).

1 Like

I will tell you the photos and contents of what I understood and acted on.

I downloaded Convolution_model_Step_by_Step_v1.ipynb and took it out.
In the first picture, I deleted files Convolution_model_Step_by_Step_v1.ipynb and
You can see the deletion results in the second picture.
In the third picture, you can see that the 404 error occurs because the file has been erased,
You have received a new update by clicking on the question mark in the upper right corner.
You can see the newly updated Convolution_model_Step_by_Step_v1.ipynb and in the fourth picture.
When I first downloaded Convolution_model_Step_by_Step_v1.ipynb, I uploaded it to Google colab, finished copying the code to coursera jupyter, and scored it,
Unfortunately, I still can’t find the function in the file and I get zero points.
Did I make a mistake?