Full code
from fastai2.collab import CollabDataLoaders
from fastai2.data.external import untar_data, URLs
import pandas as pd
path = untar_data(URLs.ML_100k)
ratings = pd.read_csv(path/'u.data', delimiter='\t', header=None,
names=['user', 'movie', 'rating', 'timestamp'])
movies = pd.read_csv(path/'u.item', delimiter='|', encoding='latin-1',
usecols=(0,1), names=('movie','title'), header=None)
ratings = ratings.merge(movies)
dls = CollabDataLoaders.from_df(ratings, item_name='title', bs=64)
x, y = dls.one_batch()
print(x.shape, y.shape)
dls.show_batch()
dls
was able to load one batch successfully, but dls.show_batch()
caused the following nasty error:
RecursionError Traceback (most recent call last)
<ipython-input-13-028278d27e82> in <module>
2 x, y = dls.one_batch()
3 print(x.shape, y.shape)
----> 4 dls.show_batch()
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/data/core.py in show_batch(self, b, max_n, ctxs, show, unique, **kwargs)
96 if b is None: b = self.one_batch()
97 if not show: return self._pre_show_batch(b, max_n=max_n)
---> 98 show_batch(*self._pre_show_batch(b, max_n=max_n), ctxs=ctxs, max_n=max_n, **kwargs)
99 if unique: self.get_idxs = old_get_idxs
100
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/data/core.py in _pre_show_batch(self, b, max_n)
86 b = self.decode(b)
87 if hasattr(b, 'show'): return b,None,None
---> 88 its = self._decode_batch(b, max_n, full=False)
89 if not is_listy(b): b,its = [b],L((o,) for o in its)
90 return detuplify(b[:self.n_inp]),detuplify(b[self.n_inp:]),its
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/data/core.py in _decode_batch(self, b, max_n, full)
80 f = self.after_item.decode
81 f = compose(f, partial(getattr(self.dataset,'decode',noop), full = full))
---> 82 return L(batch_to_samples(b, max_n=max_n)).map(f)
83
84 def _pre_show_batch(self, b, max_n=9):
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/torch_core.py in batch_to_samples(b, max_n)
531 if isinstance(b, Tensor): return retain_types(list(b[:max_n]), [b])
532 else:
--> 533 res = L(b).map(partial(batch_to_samples,max_n=max_n))
534 return retain_types(res.zip(), [b])
535
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in map(self, f, *args, **kwargs)
370 else f.format if isinstance(f,str)
371 else f.__getitem__)
--> 372 return self._new(map(g, self))
373
374 def filter(self, f, negate=False, **kwargs):
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in _new(self, items, *args, **kwargs)
321 @property
322 def _xtra(self): return None
--> 323 def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
324 def __getitem__(self, idx): return self._get(idx) if is_indexer(idx) else L(self._get(idx), use_list=None)
325 def copy(self): return self._new(self.items.copy())
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
39 return x
40
---> 41 res = super().__call__(*((x,) + args), **kwargs)
42 res._newchk = 0
43 return res
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in __init__(self, items, use_list, match, *rest)
312 if items is None: items = []
313 if (use_list is not None) or not _is_array(items):
--> 314 items = list(items) if use_list else _listify(items)
315 if match is not None:
316 if is_coll(match): match = len(match)
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in _listify(o)
248 if isinstance(o, list): return o
249 if isinstance(o, str) or _is_array(o): return [o]
--> 250 if is_iter(o): return list(o)
251 return [o]
252
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/foundation.py in __call__(self, *args, **kwargs)
214 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
215 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 216 return self.fn(*fargs, **kwargs)
217
218 # Cell
... last 7 frames repeated, from the frame below ...
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/torch_core.py in batch_to_samples(b, max_n)
531 if isinstance(b, Tensor): return retain_types(list(b[:max_n]), [b])
532 else:
--> 533 res = L(b).map(partial(batch_to_samples,max_n=max_n))
534 return retain_types(res.zip(), [b])
535
RecursionError: maximum recursion depth exceeded while calling a Python object
Anyone encountered the same issue?