[Errno 2] No such file or directory: '/tmp/cats-v-dogs/training'

I got 25 points on the notebook and this is the error log:

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:
[Errno 2] No such file or directory: ‘/tmp/cats-v-dogs/training’.

All tests passed for create_model!

I have created that directory and I can see it in the file menu, everything works perfectly. How do I fix this?

1 Like

Hi @Marta_Religa! It looks like you used root_dir (which is a global variable) within create_train_test_dirs instead of using the local root_path. Similarly for train_val_generators you probably used a global variable or hardcoded the paths instead of using the parameters of the function. Try not using any global variables within your graded functions and also not hardcoding the paths. The errors happen because the grader will wipe out all of the global state of the notebook and every graded function is unit-tested using the parameters that it has so hardcoding paths also fails the tests.

1 Like

Hi Dear a-zarta,
I am having the same problem. I couldnt solve it by myself. Here is my code and error message:


hey, for anybody is viewing this thread. I have found my problem! i used global variable in the train_val_generators() session. Now, the grading is 50/50 after correction.

basically i looked at wrong place.

2 Likes