Fastai v2 chat

That makes absolute sense! Thank you :slight_smile:

I am geeting the following error when I try to Convert LettersDL() iteator to L in 01a notebook
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
2 def create_batches(self, samps): return (string.ascii_lowercase[i:i+4] for i in range(0,26,4))
3
----> 4 test_eq(L(LettersDL()), ‘abcd,efgh,ijkl,mnop,qrst,uvwx,yz’.split(’,’))

~/ML/Fast-AI/fastai_dev/dev/local/core.py in _init(self, *args, **kwargs)
61 def _init(self,*args,**kwargs):
62 if self._newchk: return
—> 63 old_init(self, *args, **kwargs)
64
65 x.init,x.new = _init,_new

~/ML/Fast-AI/fastai_dev/dev/local/core.py in _init(self, *args, **kwargs)
34 def _init(self,*args,**kwargs):
35 self.pre_init()
—> 36 old_init(self, *args,**kwargs)
37 self.post_init()
38 setattr(x, ‘init’, _init)

~/ML/Fast-AI/fastai_dev/dev/local/core.py in init(self, items, use_list, match, rest)
242 if items is None: items = []
243 if (use_list is not None) or not isinstance(items,(Tensor,ndarray,pd.DataFrame,pd.Series)):
–> 244 items = list(items) if use_list else _listify(items)
245 if match is not None:
246 if len(items)==1: items = items
len(match)

~/ML/Fast-AI/fastai_dev/dev/local/core.py in _listify(o)
218 if isinstance(o, list): return o
219 if isinstance(o, (str,np.ndarray,Tensor)): return [o]
–> 220 if is_iter(o): return list(o)
221 return [o]
222

in iter(self)
14 assert not kwargs and not (bs is None and drop_last)
15
—> 16 def iter(self): return _loadersself.fake_l.num_workers==0
17
18 def len(self):

~/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/utils/data/dataloader.py in init(self, loader)
335 class _SingleProcessDataLoaderIter(_BaseDataLoaderIter):
336 def init(self, loader):
–> 337 super(_SingleProcessDataLoaderIter, self).init(loader)
338 assert self._timeout == 0
339 assert self._num_workers == 0

~/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/utils/data/dataloader.py in init(self, loader)
301 def init(self, loader):
302 self._dataset = loader.dataset
–> 303 self._dataset_kind = loader._dataset_kind
304 self._auto_collation = loader._auto_collation
305 self._drop_last = loader.drop_last

~/ML/Fast-AI/fastai_dev/dev/local/core.py in getattr(self, k)
193 def getattr(self,k):
194 if k in self._xtra: return getattr(self.default, k)
–> 195 raise AttributeError(k)
196 def dir(self): return custom_dir(self, self._xtra)
197

AttributeError: _dataset_kind

Can someone help?

Guessing you don’t hav PyTorch v1.2 installed, can you check your version?

My version is 1.3.0a0+60f6cc9. I built it from Pytorch git master couple of days ago.

I’ll be doing daily online code walk-thrus of fastai v2 each day from tomorrow. Details here:

8 Likes

A note for colab users who want to dev: there’s no good way to run it on windows and have it upload really… I was having git permission issues with git bash and the script for nb-strip. If anyone is familiar with git on windows that could help figure out why, here’s the output:

C:\Users\muell\Documents\fastai_dev>git add *
python tools\\fastai-nbstripout -d: /c/Users/muell/AppData/Local/Microsoft/WindowsApps/python: Permission denied
error: external filter 'python tools\\fastai-nbstripout -d' failed 126
error: external filter 'python tools\\fastai-nbstripout -d' failed
fatal: dev/04_data_external.ipynb: clean filter 'fastai-nbstripout-docs' failed

For now I’m quickly running it on paperspace after finalizing my modifications on colab…

This also occurred when I chose to run as administrator

1 Like

Look like it might be related to the new support for python in Windows, where it will take you to the windows store to install python. Check this and maybe try disabling the App execution alias, or check on your path that the correct python folder is first.

@muellerzr there’s not many things that need GPU so far in the NBs, so another option would be to just run on WSL directly.

2 Likes

Thanks Jeremy! I will try that later today! :slight_smile:

1 Like

I had a couple questions after listening to the first fastai v2 walk-thru:

  1. Why do we have functions that return functions like RandomSplitter. Wouldn’t it be more intuitive to have a class that can be called? Like in PyTorch, the nn.Modules can be called by using the forward method.

  2. In terms of the special list behavior, you demonstrate interesting behavior like adding and multiplying to the lists.

For example, you demonstrate that:

In [1]: 5*a
Out[1]: (#20) [1,2,5,7,1,2,5,7,1,2... ]

But wouldn’t it be expected to return?:

In [1]: 5*a
Out[1]: (#4) [5,10,15,35]

I don’t see why.

Try it with a regular python list and see what happens :slight_smile:

1 Like

I guess I wasn’t clear. When you were demonstrating this new list behavior, it reminded me a little bit like numpy arrays (ex: indexing with lists) and multiplying and adding numpy arrays behave differently.

You were quite clear. I still suggest you try it with a regular python list and see what happens!..

Yes I did and I see it matches python list behavior. It’s just that when you demonstrated it it reminded me of numpy arrays.

Thanks for the clarification.

1 Like

Note that python list and fastai L can hold any kind of data, not just numbers. So element-wise arithmetic doesn’t make sense for either + or *, which are two different ways of extending lists and work the same for L and list.

3 Likes

Type dispatch by parameter, and conversion of a function’s output tuple to a specified class – these are amazingly useful semantics.

Is this a built-in capability of Python, or something that the fastai developers have invented and added to Python? I can’t find an explanation in the Python docs.

Thanks for pointing me to where the magic happens.

This is fastai v2 functionality only.

So it’s implemented invisibly using some sort of code introspection? Where, how?

(I must be one of those “middle-level” Python coders.)

You got me curious, so I looked through the code a little further. It is over here:

There is a TypeDispatch class that is later used in the Transform class which is used to achieve the behavior that was demonstrated in the walk-thru.

And don’t, I am also an intermediate Python coder as well and this is a new experience for me too!