Code example in A Layered API for Deep Learning

I’m going over and I’m unable to run the first vision code example:

>>> import fastai
>>> fastai.__version__

>>> from import *
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-5635efd54484> in <module>
----> 1 from import *

ModuleNotFoundError: No module named ''

This should be from (as it’s on the new v2 version of the library)

@jeremy pinging you on this (should this be adjusted or is the end goal for it to be like this?)

Thanks for your quick reply!
I did try fastai2 before posting and the code breaks here:

dls = ImageDataLoaders.from_name_re(
AssertionError: Failed to find "re.compile('/([^/]+)_\\d+.jpg$')" in "german_shorthaired_9.jpg"

After fixing the regex, then the code breaks here:

~/miniconda3/envs/py37/lib/python3.7/site-packages/fastcore/ in __getattr__(self, k)
    221             attr = getattr(self,self._default,None)
    222             if attr is not None: return getattr(attr, k)
--> 223         raise AttributeError(k)
    224     def __dir__(self): return custom_dir(self, self._dir() if self._xtra is None else self._dir())
    225 #     def __getstate__(self): return self.__dict__

AttributeError: _IterableDataset_len_called

The _IterableDataset issue is due to the most recent torchvision. It’s recommended to use torch 1.3.1 and torchvision 0.4.2 (along with Pillow 6.2.1)

1 Like

Those versions work, it trained in 25 secs/epoch!
I just had to change:

pat = r'/([^/]+)_\d+.jpg


pat = r'([^/]+)_\d+.jpg

Does it make sense to add a function fastai.check_lib_versions() to check for the recommended library versions?

Yes the paper is written based on how things will be after fastai2 is released. At that time it’ll just be fastai.

1 Like

BTW best place to discuss fastai2 and the paper is: #fastai-users:fastai-v2

1 Like