Week4 Excercise 9 NameError: name 'L_model_backward_test_case' is not defined

Hello,

I am busy with part 1 of the assignment for week 4 course 1. Its the “Building_your_Deep_Neural_Network_Step_by_Step” assignment.

For exercise 9 I get the error “NameError: name ‘L_model_backward_test_case’ is not defined”.

Seems like a problem with the testCases library.

Can anyone help ?

Hi @Ashton in my workspace the L_model_backward_test_case() is a function defined in the file testCases.py, in the first code cell of the notebook there is also the import statement: from testCases import *. How is this on your side?

3 Likes

Hi @crisrise , thanks for your response. Mine says the same, as indicated below.

image

I have also tried restarting the kernal and executing all the cells again, but I still get this error.
The following code block (Exercise 10) also throws a similar type of error (see below).

image

Hi @Ashton have you also checked if L_model_backward_test_case() is present in the testCases.py file?

1 Like

Hi @Ashton, regarding your error with update_parameters_test_case, it is strange because if you have executed from testCases import * that error should not appear… Could you try to execute the following in a new cell before the code you’ve pasted above?

from testCases import update_parameters_test_case

If this function gives an error then there must be something wrong with your public_tests.py because that function exists.

Hi guys,

@crisrise so I checked, and L_model_backward_test_case() is in testCases.py.

@albertovilla Then I added from testCases import update_parameters_test_case to a new cell before all imports and it executed without error, but this time when I executed the update_parameters cells, the error indicated a key error.

So I decided to go through the logic of my code and I saw that I accidentally used a wrong variable and incorrect indices in two lines, in the L_model_backward function. Then I checked the update_parameters function and found a reference error.

The reason why I didn’t think it was my code was because of the error. Still not sure why logic errors could cause a function in a library to not be found…

But anyway, thanks for the help, I’ll be sure to check my code more thoroughly next time.