A walk with fastai2 - Vision - Study Group and Online Lectures Megathread

Is there any easy why to figure out what learning rates are ‘tagged’ to each layer when doing discriminative learning rate fine tuning?

I wrote a function that separated group the ResNet backbone into layer groups, basically following the hierarchy of nested Sequential models, and am now passing in a list of lr for each layer group.

However, I’m also doing this thing where I swap out layers like swapping a ReLU for Mish… which doesn’t have any params so that’s ok. But now I’m playing with swapping out layers with params and my results are funky. I’m suspecting the discriminative learning rate I applied to the pre-swap model is no longer applied correctly in the post-swap model, but I can’t figure out how to diagnose/check it. Thanks!

Sorry to bring this old message back to life but I encountered this issue as well using Windows and found out that setting num_workers=0 when creating dataloaders solved the issue. Tried this because I saw multiprocessing library was involved. It’s longer to run though obviously…

Hey Zach, I was looking at your Deployment notebook, and not sure where test_dl comes from:

  learn = load_learner(path/export_file_name)
  dl = test_dl(learn.dls, imgs)
  _, __, preds = learn.get_preds(dl=dl, with_decoded=True)

I’m trying to infer from a cnn_learner.

I need to be able to pass it the path for the image files.

My DataBlock during training looks like this:

dblk = DataBlock(blocks=(ImageBlock, CategoryBlock),

                   splitter=ColSplitter('is_valid'),

                   get_x=ColReader('fname', pref=str(path/'img') + os.path.sep),

                   get_y=ColReader('label'),

                   item_tfms = Resize(460),

                   batch_tfms=aug_transforms(size=224))

And, I tried doing this:

test_dl = learn.dls.test_dl(test_items=test_df['fname'])

inp,preds, _ , preds_raw = learn.get_preds(dl=test_dl, with_input=True, with_decoded=True)

But, it doesn’t have info on the prefix for the path. How do I fit that in?

Edit:
Earlier in the thread, you have this example:
test_dl = dls.test_dl(get_image_files(path), with_labels=True)

But, when I do that, it complains. I think it is expecting a dataframe because that is what my training dls is.

But, when I do:

test_dl = learn.dls.test_dl(test_df, with_labels=True)
_, __, preds = learn.get_preds(dl=dl, with_decoded=True)

it complains about not finding the img in the path where I have my training imgs.

FileNotFoundError: [Errno 2] No such file or directory: '/content/gdrive/My Drive/img/Test_0_20200308_013537_0_0.jpg'

How do I override the path for the test_imgs?

@muellerzr, I followed your new blog (thanks for putting that up, I have to read it multiple times :slight_smile: ), and came up with this:

test_pipe = Pipeline([ColReader('fname', pref=str(path/'test_img') + os.path.sep), PILImage.create]) 
dls_over.valid_ds.tls[0].tfms = test_pipe

And, tested it with:

e = test_set(learn.dls.valid_ds, test_df)

And, it doesn’t fail.

But, when I now try to infer, I’m seeing this issue:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in _do_epoch_validate(self, ds_idx, dl)
    184             self.dl = dl;                                    self('begin_validate')
--> 185             with torch.no_grad(): self.all_batches()
    186         except CancelValidException:                         self('after_cancel_validate')

20 frames
/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in all_batches(self)
    154         self.n_iter = len(self.dl)
--> 155         for o in enumerate(self.dl): self.one_batch(*o)
    156 

/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py in __iter__(self)
     97         self.before_iter()
---> 98         for b in _loaders[self.fake_l.num_workers==0](self.fake_l):
     99             if self.device is not None: b = to_device(b, self.device)

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in __next__(self)
    362     def __next__(self):
--> 363         data = self._next_data()
    364         self._num_yielded += 1

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _next_data(self)
    988                 del self._task_info[idx]
--> 989                 return self._process_data(data)
    990 

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _process_data(self, data)
   1013         if isinstance(data, ExceptionWrapper):
-> 1014             data.reraise()
   1015         return data

/usr/local/lib/python3.6/dist-packages/torch/_utils.py in reraise(self)
    394             msg = KeyErrorMessage(msg)
--> 395         raise self.exc_type(msg)

KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
    data = fetcher.fetch(index)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 34, in fetch
    data = next(self.dataset_iter)
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 107, in create_batches
    yield from map(self.do_batch, self.chunkify(res))
  File "/usr/local/lib/python3.6/dist-packages/fastcore/utils.py", line 299, in chunked
    res = list(itertools.islice(it, chunk_sz))
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 120, in do_item
    try: return self.after_item(self.create_item(s))
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 126, in create_item
    def create_item(self, s):  return next(self.it) if s is None else self.dataset[s]
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py", line 293, in __getitem__
    res = tuple([tl[it] for tl in self.tls])
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py", line 293, in <listcomp>
    res = tuple([tl[it] for tl in self.tls])
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py", line 270, in __getitem__
    return self._after_item(res) if is_indexer(idx) else res.map(self._after_item)
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py", line 232, in _after_item
    def _after_item(self, o): return self.tfms(o)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 202, in __call__
    def __call__(self, o): return compose_tfms(o, tfms=self.fs, split_idx=self.split_idx)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 155, in compose_tfms
    x = f(x, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 72, in __call__
    def __call__(self, x, **kwargs): return self._call('encodes', x, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 82, in _call
    return self._do_call(getattr(self, fn), x, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 88, in _do_call
    return retain_type(f(x, **kwargs), x, ret)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/dispatch.py", line 99, in __call__
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/transforms.py", line 244, in encodes
    def encodes(self, o): return TensorCategory(self.vocab.o2i[o])
KeyError: ''


During handling of the above exception, another exception occurred:

IndexError                                Traceback (most recent call last)
<ipython-input-93-eb42554961cb> in <module>()
----> 1 inp,preds, _ , preds_raw = learn.get_preds(dl=my_test_dl, with_input=True, with_decoded=True)

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in get_preds(self, ds_idx, dl, with_input, with_decoded, with_loss, act, inner, reorder, cbs, **kwargs)
    234             for mgr in ctx_mgrs: stack.enter_context(mgr)
    235             self(event.begin_epoch if inner else _before_epoch)
--> 236             self._do_epoch_validate(dl=dl)
    237             self(event.after_epoch if inner else _after_epoch)
    238             if act is None: act = getattr(self.loss_func, 'activation', noop)

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in _do_epoch_validate(self, ds_idx, dl)
    185             with torch.no_grad(): self.all_batches()
    186         except CancelValidException:                         self('after_cancel_validate')
--> 187         finally:                                             self('after_validate')
    188 
    189     def _end_cleanup(self):

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in __call__(self, event_name)
    134     def ordered_cbs(self, event): return [cb for cb in sort_by_run(self.cbs) if hasattr(cb, event)]
    135 
--> 136     def __call__(self, event_name): L(event_name).map(self._call_one)
    137     def _call_one(self, event_name):
    138         assert hasattr(event, event_name)

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in map(self, f, *args, **kwargs)
    381              else f.format if isinstance(f,str)
    382              else f.__getitem__)
--> 383         return self._new(map(g, self))
    384 
    385     def filter(self, f, negate=False, **kwargs):

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in _new(self, items, *args, **kwargs)
    331     @property
    332     def _xtra(self): return None
--> 333     def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
    334     def __getitem__(self, idx): return self._get(idx) if is_indexer(idx) else L(self._get(idx), use_list=None)
    335     def copy(self): return self._new(self.items.copy())

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
     45             return x
     46 
---> 47         res = super().__call__(*((x,) + args), **kwargs)
     48         res._newchk = 0
     49         return res

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __init__(self, items, use_list, match, *rest)
    322         if items is None: items = []
    323         if (use_list is not None) or not _is_array(items):
--> 324             items = list(items) if use_list else _listify(items)
    325         if match is not None:
    326             if is_coll(match): match = len(match)

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in _listify(o)
    258     if isinstance(o, list): return o
    259     if isinstance(o, str) or _is_array(o): return [o]
--> 260     if is_iter(o): return list(o)
    261     return [o]
    262 

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __call__(self, *args, **kwargs)
    224             if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
    225         fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 226         return self.fn(*fargs, **kwargs)
    227 
    228 # Cell

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in _call_one(self, event_name)
    137     def _call_one(self, event_name):
    138         assert hasattr(event, event_name)
--> 139         [cb(event_name) for cb in sort_by_run(self.cbs)]
    140 
    141     def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in <listcomp>(.0)
    137     def _call_one(self, event_name):
    138         assert hasattr(event, event_name)
--> 139         [cb(event_name) for cb in sort_by_run(self.cbs)]
    140 
    141     def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)

/usr/local/lib/python3.6/dist-packages/fastai2/callback/core.py in __call__(self, event_name)
     42                (self.run_valid and not getattr(self, 'training', False)))
     43         res = None
---> 44         if self.run and _run: res = getattr(self, event_name, noop)()
     45         if event_name=='after_fit': self.run=True #Reset self.run to True at each end of fit
     46         return res

/usr/local/lib/python3.6/dist-packages/fastai2/callback/core.py in after_validate(self)
    115     def after_validate(self):
    116         "Concatenate all recorded tensors"
--> 117         if self.with_input:     self.inputs  = detuplify(to_concat(self.inputs, dim=self.concat_dim))
    118         if not self.save_preds: self.preds   = detuplify(to_concat(self.preds, dim=self.concat_dim))
    119         if not self.save_targs: self.targets = detuplify(to_concat(self.targets, dim=self.concat_dim))

/usr/local/lib/python3.6/dist-packages/fastai2/torch_core.py in to_concat(xs, dim)
    217 def to_concat(xs, dim=0):
    218     "Concat the element in `xs` (recursively if they are tuples/lists of tensors)"
--> 219     if is_listy(xs[0]): return type(xs[0])([to_concat([x[i] for x in xs], dim=dim) for i in range_of(xs[0])])
    220     if isinstance(xs[0],dict):  return {k: to_concat([x[k] for x in xs], dim=dim) for k in xs[0].keys()}
    221     #We may receives xs that are not concatenatable (inputs of a text classifier for instance),

IndexError: list index out of range

I can’t recreate your issue using my example in the article (even passing it with the params you used), so not entirely sure what’s going on. While test_set may not fail, does it successfully turn your items to a set? IE did you look in it?

Edit: actually why are you using os.path.sep? Does it work without it? Because I don’t recall it should be needed

Yea, we need the os.path.sep to tell what goes between the prefix and the fname. Just removed it and it fails even for the training dataloader.

OK, so I did check that my test_images are found when I make the new test_set.

a = test_set(learn.dls.valid_ds, test_df)
a
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in __call__(self, obj)
    697                 type_pprinters=self.type_printers,
    698                 deferred_pprinters=self.deferred_printers)
--> 699             printer.pretty(obj)
    700             printer.flush()
    701             return stream.getvalue()

18 frames
/usr/local/lib/python3.6/dist-packages/PIL/Image.py in open(fp, mode)
   2807 
   2808     if filename:
-> 2809         fp = builtins.open(filename, "rb")
   2810         exclusive_fp = True
   2811 

FileNotFoundError: [Errno 2] No such file or directory: '/content/gdrive/My Drive/img/Test_0_20_0_0.jpg'

learn.dls.valid_ds.tls[0].tfms.fs
(#2) [ColReader:
encodes: (object,object) -> ColReaderdecodes: ,PILBase.create:
encodes: (bytes,object) -> create
(ndarray,object) -> create
(Tensor,object) -> create
(str,object) -> create
(Path,object) -> createdecodes: ]

And then:

test_pipe = Pipeline([ColReader('fname', pref=str(path/'test_img')), PILImage.create])

test_pipe.fs
(#2) [ColReader:
encodes: (object,object) -> ColReaderdecodes: ,PILBase.create:
encodes: (bytes,object) -> create
(ndarray,object) -> create
(Tensor,object) -> create
(str,object) -> create
(Path,object) -> createdecodes: ]

learn.dls.valid_ds.tls[0].tfms = test_pipe
e = test_set(learn.dls.valid_ds, test_df)
e
(#99) [(PILImage mode=RGB size=1535x1832,),(PILImage mode=RGB size=1970x1694,),....

And, I see the error above when I try to infer.

I changed my df to further isolate the issue.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in _do_epoch_validate(self, ds_idx, dl)
    184             self.dl = dl;                                    self('begin_validate')
--> 185             with torch.no_grad(): self.all_batches()
    186         except CancelValidException:                         self('after_cancel_validate')

20 frames
/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in all_batches(self)
    154         self.n_iter = len(self.dl)
--> 155         for o in enumerate(self.dl): self.one_batch(*o)
    156 

/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py in __iter__(self)
     97         self.before_iter()
---> 98         for b in _loaders[self.fake_l.num_workers==0](self.fake_l):
     99             if self.device is not None: b = to_device(b, self.device)

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in __next__(self)
    362     def __next__(self):
--> 363         data = self._next_data()
    364         self._num_yielded += 1

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _next_data(self)
    988                 del self._task_info[idx]
--> 989                 return self._process_data(data)
    990 

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _process_data(self, data)
   1013         if isinstance(data, ExceptionWrapper):
-> 1014             data.reraise()
   1015         return data

/usr/local/lib/python3.6/dist-packages/torch/_utils.py in reraise(self)
    394             msg = KeyErrorMessage(msg)
--> 395         raise self.exc_type(msg)

AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
    data = fetcher.fetch(index)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 34, in fetch
    data = next(self.dataset_iter)
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 107, in create_batches
    yield from map(self.do_batch, self.chunkify(res))
  File "/usr/local/lib/python3.6/dist-packages/fastcore/utils.py", line 299, in chunked
    res = list(itertools.islice(it, chunk_sz))
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 120, in do_item
    try: return self.after_item(self.create_item(s))
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 126, in create_item
    def create_item(self, s):  return next(self.it) if s is None else self.dataset[s]
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py", line 293, in __getitem__
    res = tuple([tl[it] for tl in self.tls])
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py", line 293, in <listcomp>
    res = tuple([tl[it] for tl in self.tls])
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py", line 270, in __getitem__
    return self._after_item(res) if is_indexer(idx) else res.map(self._after_item)
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py", line 232, in _after_item
    def _after_item(self, o): return self.tfms(o)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 202, in __call__
    def __call__(self, o): return compose_tfms(o, tfms=self.fs, split_idx=self.split_idx)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 155, in compose_tfms
    x = f(x, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 72, in __call__
    def __call__(self, x, **kwargs): return self._call('encodes', x, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 82, in _call
    return self._do_call(getattr(self, fn), x, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/transform.py", line 88, in _do_call
    return retain_type(f(x, **kwargs), x, ret)
  File "/usr/local/lib/python3.6/dist-packages/fastcore/dispatch.py", line 99, in __call__
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/transforms.py", line 200, in __call__
    if len(self.cols) == 1: return self._do_one(o, self.cols[0])
  File "/usr/local/lib/python3.6/dist-packages/fastai2/data/transforms.py", line 194, in _do_one
    o = r[c] if isinstance(c, int) else r[c] if c=='name' else getattr(r, c)
  File "/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py", line 5274, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'label'


During handling of the above exception, another exception occurred:

IndexError                                Traceback (most recent call last)
<ipython-input-66-20418d1421e1> in <module>()
----> 1 preds = learn.get_preds(dl=my_test_dl)

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in get_preds(self, ds_idx, dl, with_input, with_decoded, with_loss, act, inner, reorder, cbs, **kwargs)
    234             for mgr in ctx_mgrs: stack.enter_context(mgr)
    235             self(event.begin_epoch if inner else _before_epoch)
--> 236             self._do_epoch_validate(dl=dl)
    237             self(event.after_epoch if inner else _after_epoch)
    238             if act is None: act = getattr(self.loss_func, 'activation', noop)

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in _do_epoch_validate(self, ds_idx, dl)
    185             with torch.no_grad(): self.all_batches()
    186         except CancelValidException:                         self('after_cancel_validate')
--> 187         finally:                                             self('after_validate')
    188 
    189     def _end_cleanup(self):

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in __call__(self, event_name)
    134     def ordered_cbs(self, event): return [cb for cb in sort_by_run(self.cbs) if hasattr(cb, event)]
    135 
--> 136     def __call__(self, event_name): L(event_name).map(self._call_one)
    137     def _call_one(self, event_name):
    138         assert hasattr(event, event_name)

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in map(self, f, *args, **kwargs)
    381              else f.format if isinstance(f,str)
    382              else f.__getitem__)
--> 383         return self._new(map(g, self))
    384 
    385     def filter(self, f, negate=False, **kwargs):

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in _new(self, items, *args, **kwargs)
    331     @property
    332     def _xtra(self): return None
--> 333     def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
    334     def __getitem__(self, idx): return self._get(idx) if is_indexer(idx) else L(self._get(idx), use_list=None)
    335     def copy(self): return self._new(self.items.copy())

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
     45             return x
     46 
---> 47         res = super().__call__(*((x,) + args), **kwargs)
     48         res._newchk = 0
     49         return res

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __init__(self, items, use_list, match, *rest)
    322         if items is None: items = []
    323         if (use_list is not None) or not _is_array(items):
--> 324             items = list(items) if use_list else _listify(items)
    325         if match is not None:
    326             if is_coll(match): match = len(match)

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in _listify(o)
    258     if isinstance(o, list): return o
    259     if isinstance(o, str) or _is_array(o): return [o]
--> 260     if is_iter(o): return list(o)
    261     return [o]
    262 

/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __call__(self, *args, **kwargs)
    224             if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
    225         fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 226         return self.fn(*fargs, **kwargs)
    227 
    228 # Cell

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in _call_one(self, event_name)
    137     def _call_one(self, event_name):
    138         assert hasattr(event, event_name)
--> 139         [cb(event_name) for cb in sort_by_run(self.cbs)]
    140 
    141     def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)

/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in <listcomp>(.0)
    137     def _call_one(self, event_name):
    138         assert hasattr(event, event_name)
--> 139         [cb(event_name) for cb in sort_by_run(self.cbs)]
    140 
    141     def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)

/usr/local/lib/python3.6/dist-packages/fastai2/callback/core.py in __call__(self, event_name)
     42                (self.run_valid and not getattr(self, 'training', False)))
     43         res = None
---> 44         if self.run and _run: res = getattr(self, event_name, noop)()
     45         if event_name=='after_fit': self.run=True #Reset self.run to True at each end of fit
     46         return res

/usr/local/lib/python3.6/dist-packages/fastai2/callback/core.py in after_validate(self)
    116         "Concatenate all recorded tensors"
    117         if self.with_input:     self.inputs  = detuplify(to_concat(self.inputs, dim=self.concat_dim))
--> 118         if not self.save_preds: self.preds   = detuplify(to_concat(self.preds, dim=self.concat_dim))
    119         if not self.save_targs: self.targets = detuplify(to_concat(self.targets, dim=self.concat_dim))
    120         if self.with_loss:      self.losses  = to_concat(self.losses)

/usr/local/lib/python3.6/dist-packages/fastai2/torch_core.py in to_concat(xs, dim)
    217 def to_concat(xs, dim=0):
    218     "Concat the element in `xs` (recursively if they are tuples/lists of tensors)"
--> 219     if is_listy(xs[0]): return type(xs[0])([to_concat([x[i] for x in xs], dim=dim) for i in range_of(xs[0])])
    220     if isinstance(xs[0],dict):  return {k: to_concat([x[k] for x in xs], dim=dim) for k in xs[0].keys()}
    221     #We may receives xs that are not concatenatable (inputs of a text classifier for instance),

IndexError: list index out of range

This is curious:

AttributeError: 'Series' object has no attribute 'label'

I think because of the get_y in the original DataBlock, it is looking for it in the test.csv. Tests are not supposed to have labels.

@shimsan how are you building the test_dl in these cases? I’d assume with_label=False?

1 Like

Oh shoot, I had that on! My bad!
Thanks :slight_smile:

I had it off for a while, and in my manic debug, was flipping some switches :laughing:

2 Likes
batch_tfms = [*aug_transforms(size=224, max_warp=0), Normalize.from_stats(*imagenet_stats)]

What does the * in *aug_transforms() mean ? Also in the *imagenet_stats ?
Thanks.

It’s python code. https://stackoverflow.com/questions/2921847/what-does-the-star-operator-mean-in-a-function-call

3 Likes

I executed again the code from the object detection notebook. Bounding boxes shown after dls.show_batch() are off. Need to check if it’s because transforms are not applied to bounding boxes or if it’s a display issue.

I’ll look into the OD notebooks today. The issue is not providing Pad to the resize method. Like so:

item_tfms = [Resize(128, method='pad'),]
batch_tfms = [Rotate(), Flip(), Dihedral(), Normalize.from_stats(*imagenet_stats)]

Thanks :slight_smile: Mmh I tried with Pad method and didn’t get better results unfortunately

Since the library is being released today, the notebooks reflect this change (ie it now says from fastai.vision.all, etc). If you are viewing the notebooks and the pip version hasn’t been released yet (you will know, it’ll be posted everywhere :wink: ), still use pip install fastai2 and fastai2 instead of fastai

1 Like

I decided to start it now! do I need to clone fastai/fastai_dev for anything except notebooks? Or can I catch up with my conda installation of official fastai?

The notebooks can be run top down :slight_smile: simply pip install the latest fastai (you may need a pip w/ upgrade to get it)

1 Like

that’s great, thanks.

Okay I got my first problem!

In pets notebook in dev directory of repo, there is this class which inherits from Tuple; however, it says its not defined. I searched the repo with Sourcegraph and found the definition of Tuple but I assume its name has been changed after releasing the official version.
Does anyone know what’s happening here?

Ah Tuple needs to be fastuple. Which notebook is this exactly? And which repo?