Name ‘TESTING_DIR’ is not defined

Hi All,
I was able to succesfully run the TF1 Course2 Week 1 coding assignemnt for Cats and Dogs dataset. However there is some issue being thrown when I submit it for evaluation as follows:


Details of failed tests for create_train_test_dirs

Failed test case: There was an error grading this function. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
name ‘root_dir’ is not defined.

All tests passed for split_data!

Details of failed tests for train_val_generators

Failed test case: There was an error grading this function. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
name ‘TESTING_DIR’ is not defined.

All tests passed for create_model!


Can anyone please suggest anything to tackle it?

Hi @Suraj13

It looks like you are using a variable that you didn’t define.
Try to go throught your notebook and check where the problem was raised and be sure you are not using VALIDATION and TESTING interchangeably.

Thank you and hope this helps !

Hi @Suraj13,

This is most likely because you are using global variables within your graded functions. You should use the parameters passed to the functions instead of globals as mentioned in the instructions for the assignment (in coursera before going to the notebook). For example, train_val_generators should use the variable VALIDATION_DIR and not the global TESTING_DIR . Probably a similar case happens with your other function.

The grader wipes out all of the global state in the notebook so as @Wael_BEN_MSAAD mentions, it is as if TESTING_DIR and root_dir where never defined.

Thank for the suggestion @Wael_BEN_MSAAD but I have been consistent in scopes inside functions as well (only local variables are used), as you suggest. The issue stilll persists. I will try to check further for any other issue.

1 Like

Hello Suraj,

I’m glad to see you here. The problem seems to come from the function def create_train_test_dirs(root_path). Does your output correspond to the expected output (directory order might vary)?