Redux: Import Utils Errors

When setting up redux, for the import in the third cell, I’m getting this error:

ImportError                               Traceback (most recent call last)
<ipython-input-3-b5efe9affb9b> in <module>()
      3 
      4 #import modules
----> 5 from utils import *
      6 from vgg16 import Vgg16
      7 

ImportError: No module named utils

The directions seem to indicate that vgg16.py and utils.py belong in a directory “utils”:

utils/
    vgg16.py
    utils.py

I assumed that I had copied the utils folder to the wrong directory. Should it be in deeplearning1 along side lesson1, or above lesson1? Neither seems to work. Where should the lesson1 directory ideally be located?

In a separate thread, Jeremy indicated that vgg16.py and utils.py should be in the same directory as the executed notebook. That seems to work, except that I get an avalanche of source code (5392 lines), ending with:

WARNING (then.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable) Using Theano backend.

Happy to supply further details…

Alongside the lesson1 - if you look to Github repo, you’ll see that these files are in deeplearning1/nbs/ directory together with notebooks

Yes, thanks, Alex. The ambiguous part is that they are not in a folder called “utils” which is what the instructions seem to indicate. There is also no “lesson1” folder. Here is how the setup is described:

To start you will need to download and unzip the competition data from Kaggle and ensure your directory structure looks like this

utils/
    vgg16.py
    utils.py
lesson1/
    redux.ipynb
    data/
        redux/
            train/
                cat.437.jpg
                dog.9924.jpg
                cat.1029.jpg
                dog.4374.jpg
            test/
                231.jpg
                325.jpg
                1235.jpg
                9923.jpg

hi, I ran into the same problem. Adding a __init__.py in the utils directory solved this problem. For more details, please check https://stackoverflow.com/questions/4383571/importing-files-from-different-folder.

BYW, you might need to restart your notebook so that the notebook can find the module. Have fun.

1 Like