Course 4 Week 1 Assignment 1 Exercise 3: conv_forward_test not defined

Hi all,

I am having an issue with Course 4 Week 1 Assignment 1 Exercise 3. I worked on the assignment yesterday and successfully completed this step, but it seems like the assignment has been updated since then and the testing is broken, i.e. I get this error when running the test cell

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

NameError: name 'conv_forward_test' is not defined

and indeed, if we look in public_tests.py there is no conv_forward_test function but rather there are two named conv_forward_test_1 and conv_forward_test_2. Any help would be appreciated :slight_smile:

If this is due to version update the documentation here will come of help. You can refresh your lab. Please look under the heading : Refresh your lab Workspace.

Link to Documentation

Yes, this assignment is being updated to improve the quality of the unit tests.

You may have to save your notebook locally, delete all of the files from your workspace, and then reinstall the exercise.
Then you can re-upload your notebook.

Here is Coursera’s guidance on this.
https://www.coursera.support/s/article/360004995312-Solve-problems-with-Jupyter-Notebooks?language=en_US

The course also has an FAQ, I’ll update this post with the link shortly.

Rather than use the generic Coursera links, it’s better to use the “Get a Clean Copy” procedure documented on our local FAQ Thread. That is fully in tune with exactly the way things work here in DLS.

I’m not sure how you ended up in this scenario. The way I thought this works is that the new version overrides your current version and moves it aside. Then the “Work in Browser” link makes it look like your work has disappeared. So then you have to open your old notebook (saved with the date interpolated into the name) in parallel with the new one and then carefully “copy/paste” over any completed work. Don’t copy whole cells: just copy your code between the “START CODE HERE” and “END CODE HERE” blocks.

But apparently you get the new test files, but not the new notebook. Follow the ‘Get a Clean Copy’ procedure, which involves renaming your current notebook. Then carefully do the “copy/paste” into the new clean copy and that should fix things.

Thanks for the input, everyone! I think I now have everything procedurally set up at least. I am, however, having an issue with my code failing the first conv_forward_test but passing the second. I’ve looked through the forum to see other people’s issues, but I think I’m missing the “common” pitfalls, i.e. I’m looping over the output volume. Could you please take a look?

My current work is in Convolution_model_Step_by_Step_v1 and my lab id is wwtpkfhp

Edit: The output looks like this

Z's mean =
 0.5329033220060434
Z[0,2,1] =
 [-0.05723279  0.03991888 -6.24285862  0.53960581 -5.04059676  6.96991358
  3.69509379 -0.20955895]
cache_conv[0][1][2][3] =
 [-1.1191154   1.9560789  -0.3264995  -1.34267579]
First Test: Z's mean is incorrect. Expected: 0.5511276474566768 
Your output: 0.5329033220060434 

First Test: Z[0,2,1] is incorrect. Expected: [-2.17796037, 8.07171329, -0.5772704, 3.36286738, 4.48113645, -2.89198428, 10.99288867, 3.03171932] 
Your output: [-0.05723279  0.03991888 -6.24285862  0.53960581 -5.04059676  6.96991358
  3.69509379 -0.20955895] 

Second Test: All tests passed!

Please realize that only the course staff can use your lab id to examine your notebooks and they are way too busy to be listening here on most days anyway. The mentors are just fellow student (volunteers) who do not have that superpower.

Well, you pass one test, but fail the other. So what is different about the two tests? You can examine the source code by clicking “File → Open” and having a look around. This was mentioned on the FAQ Thread FWIW …

Mind you, these tests are brand new as of today and I have not personally had time to look at them yet. The problem that they are intended to fix is that the previous tests did not catch the error if you omitted the stride in your calculations.

Ok, I just took a look at the changes that were made. Note that the first test case is just checking the results of a stride = 2 test case. The second test is just the old tests under a new name: it includes several stride values, but only checks the actual results in the stride = 1 test cases, which was the original problem.

So I think the first theory would be that you have made the most popular mistake here and not implemented the stride correctly. You are looping over the output space and must not skip any positions there, right? The stride happens in the input space and for each h and w value in the output space, you need to calculate where you are in the input space.

Thanks! I saw mentions of this in other posts but didn’t really put it together; the question in your second paragraph was what did it.