Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change param name copy_meta->as_copy in retain_meta` #157

Closed
jph00 opened this issue Oct 29, 2020 · 2 comments
Closed

change param name copy_meta->as_copy in retain_meta` #157

jph00 opened this issue Oct 29, 2020 · 2 comments
Labels

Comments

@jph00
Copy link
Member

jph00 commented Oct 29, 2020

No description provided.

@jph00 jph00 added the breaking label Oct 29, 2020
@jph00 jph00 closed this as completed in 40eb135 Oct 29, 2020
@kmad
Copy link

kmad commented Oct 30, 2020

FYI this completely breaks the 01_intro notebook examples (and likely other areas as well) when running on a fresh install of the docker image. Reverting these changes fixed the issue. Perhaps this should be on a different branch?

Output below:

--------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-2590e3bef449> in <module>
      6 
      7 def is_cat(x): return x[0].isupper()
----> 8 dls = ImageDataLoaders.from_name_func(
      9     path, get_image_files(path), valid_pct=0.2, seed=42,
     10     label_func=is_cat, item_tfms=Resize(224))

/opt/conda/lib/python3.8/site-packages/fastai/vision/data.py in from_name_func(cls, path, fnames, label_func, **kwargs)
    109         "Create from the name attrs of `fnames` in `path`s with `label_func`"
    110         f = using_attr(label_func, 'name')
--> 111         return cls.from_path_func(path, fnames, f, **kwargs)
    112 
    113     @classmethod

/opt/conda/lib/python3.8/site-packages/fastai/vision/data.py in from_path_func(cls, path, fnames, label_func, valid_pct, seed, item_tfms, batch_tfms, **kwargs)
    103                            item_tfms=item_tfms,
    104                            batch_tfms=batch_tfms)
--> 105         return cls.from_dblock(dblock, fnames, path=path, **kwargs)
    106 
    107     @classmethod

/opt/conda/lib/python3.8/site-packages/fastai/data/core.py in from_dblock(cls, dblock, source, path, bs, val_bs, shuffle_train, device, **kwargs)
    178     @classmethod
    179     def from_dblock(cls, dblock, source, path='.',  bs=64, val_bs=None, shuffle_train=True, device=None, **kwargs):
--> 180         return dblock.dataloaders(source, path=path, bs=bs, val_bs=val_bs, shuffle_train=shuffle_train, device=device, **kwargs)
    181 
    182     _docs=dict(__getitem__="Retrieve `DataLoader` at `i` (`0` is training, `1` is validation)",

/opt/conda/lib/python3.8/site-packages/fastai/data/block.py in dataloaders(self, source, path, verbose, **kwargs)
    111 
    112     def dataloaders(self, source, path='.', verbose=False, **kwargs):
--> 113         dsets = self.datasets(source)
    114         kwargs = {**self.dls_kwargs, **kwargs, 'verbose': verbose}
    115         return dsets.dataloaders(path=path, after_item=self.item_tfms, after_batch=self.batch_tfms, **kwargs)

/opt/conda/lib/python3.8/site-packages/fastai/data/block.py in datasets(self, source, verbose)
    108         splits = (self.splitter or RandomSplitter())(items)
    109         pv(f"{len(splits)} datasets of sizes {','.join([str(len(s)) for s in splits])}", verbose)
--> 110         return Datasets(items, tfms=self._combine_type_tfms(), splits=splits, dl_type=self.dl_type, n_inp=self.n_inp, verbose=verbose)
    111 
    112     def dataloaders(self, source, path='.', verbose=False, **kwargs):

/opt/conda/lib/python3.8/site-packages/fastai/data/core.py in __init__(self, items, tfms, tls, n_inp, dl_type, **kwargs)
    308     def __init__(self, items=None, tfms=None, tls=None, n_inp=None, dl_type=None, **kwargs):
    309         super().__init__(dl_type=dl_type)
--> 310         self.tls = L(tls if tls else [TfmdLists(items, t, **kwargs) for t in L(ifnone(tfms,[None]))])
    311         self.n_inp = ifnone(n_inp, max(1, len(self.tls)-1))
    312 

/opt/conda/lib/python3.8/site-packages/fastai/data/core.py in <listcomp>(.0)
    308     def __init__(self, items=None, tfms=None, tls=None, n_inp=None, dl_type=None, **kwargs):
    309         super().__init__(dl_type=dl_type)
--> 310         self.tls = L(tls if tls else [TfmdLists(items, t, **kwargs) for t in L(ifnone(tfms,[None]))])
    311         self.n_inp = ifnone(n_inp, max(1, len(self.tls)-1))
    312 

/opt/conda/lib/python3.8/site-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
    161     def __call__(cls, x=None, *args, **kwargs):
    162         if not args and not kwargs and x is not None and isinstance(x,cls): return x
--> 163         return super().__call__(x, *args, **kwargs)
    164 
    165 # Cell

/opt/conda/lib/python3.8/site-packages/fastai/data/core.py in __init__(self, items, tfms, use_list, do_setup, split_idx, train_setup, splits, types, verbose, dl_type)
    234         if do_setup:
    235             pv(f"Setting up {self.tfms}", verbose)
--> 236             self.setup(train_setup=train_setup)
    237 
    238     def _new(self, items, split_idx=None, **kwargs):

/opt/conda/lib/python3.8/site-packages/fastai/data/core.py in setup(self, train_setup)
    256             for f in self.tfms.fs:
    257                 self.types.append(getattr(f, 'input_types', type(x)))
--> 258                 x = f(x)
    259             self.types.append(type(x))
    260         types = L(t if is_listy(t) else [t] for t in self.types).concat().unique()

/opt/conda/lib/python3.8/site-packages/fastcore/transform.py in __call__(self, x, **kwargs)
     71     @property
     72     def name(self): return getattr(self, '_name', _get_name(self))
---> 73     def __call__(self, x, **kwargs): return self._call('encodes', x, **kwargs)
     74     def decode  (self, x, **kwargs): return self._call('decodes', x, **kwargs)
     75     def __repr__(self): return f'{self.name}:\nencodes: {self.encodes}decodes: {self.decodes}'

/opt/conda/lib/python3.8/site-packages/fastcore/transform.py in _call(self, fn, x, split_idx, **kwargs)
     81     def _call(self, fn, x, split_idx=None, **kwargs):
     82         if split_idx!=self.split_idx and self.split_idx is not None: return x
---> 83         return self._do_call(getattr(self, fn), x, **kwargs)
     84 
     85     def _do_call(self, f, x, **kwargs):

/opt/conda/lib/python3.8/site-packages/fastcore/transform.py in _do_call(self, f, x, **kwargs)
     87             if f is None: return x
     88             ret = f.returns_none(x) if hasattr(f,'returns_none') else None
---> 89             return retain_type(f(x, **kwargs), x, ret)
     90         res = tuple(self._do_call(f, x_, **kwargs) for x_ in x)
     91         return retain_type(res, x)

/opt/conda/lib/python3.8/site-packages/fastcore/dispatch.py in __call__(self, *args, **kwargs)
    127         elif self.inst is not None: f = MethodType(f, self.inst)
    128         elif self.owner is not None: f = MethodType(f, self.owner)
--> 129         return f(*args, **kwargs)
    130 
    131     def __get__(self, inst, owner):

/opt/conda/lib/python3.8/site-packages/fastai/data/transforms.py in encodes(self, o)
    240     def encodes(self, o):
    241         try:
--> 242             return TensorCategory(self.vocab.o2i[o])
    243         except KeyError as e:
    244             raise KeyError(f"Label '{o}' was not included in the training dataset") from e

/opt/conda/lib/python3.8/site-packages/fastai/torch_core.py in __new__(cls, x, **kwargs)
    300 class TensorBase(Tensor):
    301     def __new__(cls, x, **kwargs):
--> 302         res = cast(tensor(x), cls)
    303         if kwargs: res._meta = kwargs
    304         return res

/opt/conda/lib/python3.8/site-packages/fastcore/dispatch.py in __call__(self, *args, **kwargs)
    127         elif self.inst is not None: f = MethodType(f, self.inst)
    128         elif self.owner is not None: f = MethodType(f, self.owner)
--> 129         return f(*args, **kwargs)
    130 
    131     def __get__(self, inst, owner):

/opt/conda/lib/python3.8/site-packages/fastcore/dispatch.py in cast(x, typ)
    188     res = typ._before_cast(x) if hasattr(typ, '_before_cast') else x
    189     if isinstance_str(res, 'ndarray'): res = res.view(typ)
--> 190     elif hasattr(res, 'as_subclass'): res = res.as_subclass(typ)
    191     else:
    192         try: res.__class__ = typ

/opt/conda/lib/python3.8/site-packages/fastai/torch_core.py in as_subclass(self, typ)
    295 def as_subclass(self:Tensor, typ):
    296     "Cast to `typ` and include `__dict__` and meta"
--> 297     return retain_meta(self, torch.as_subclass(self, typ))
    298 
    299 # Cell

/opt/conda/lib/python3.8/site-packages/fastcore/dispatch.py in retain_meta(x, res, as_copy)
    170 def retain_meta(x, res, as_copy=False):
    171     "Call `res.set_meta(x)`, if it exists"
--> 172     if hasattr(res,'set_meta'): res.set_meta(x, as_copy=as_copy)
    173     return res
    174 

/opt/conda/lib/python3.8/site-packages/fastai/torch_core.py in _f(self, *args, **kwargs)
    329         def _f(self, *args, **kwargs):
    330             cls = self.__class__
--> 331             res = getattr(super(TensorBase, self), fn)(*args, **kwargs)
    332             return retain_type(res, self, copy_meta=True)
    333         return _f

TypeError: set_meta() got an unexpected keyword argument 'as_copy'

@jph00
Copy link
Member Author

jph00 commented Oct 30, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants