That’s correct sir
Hmmm… let me investigate
I even tried to create my own Cuda tfms but failed =X
Anything batch related is automatically pushed to the GPU if it’s available, hence why we don’t have it anymore Running it now, will report back shortly if I can figure out what it may be.
@lgvaz instead of installing from git, what does just installing fastai2 do?
I must be doing something wrong then, my tensors are not defaulting to cuda.
If I do:
But if I do:
It works, and now it’s in cuda…
Hmmm. That’s actually a good point. I’m noticing this too… ping @sgugger? What do you think is happening here?
Ha! so the solution was to override the device of our dataloader to cuda @lgvaz
dl.device = 'cuda'
which is weird considering it’s not being set
You should not use the Cuda transform anymore (it doesn’t exist in v2 or won’t very soon) but pass a device to your DataLoader
/TfmdDL
.
Got it, thank you
Datasets
currently shows **kwargs
. If I remember correctly Jeremy mentioned that is not expected behaviour because of delegation. But at the same time i know Datasets
is a recent change so maybe they are working on it. Should this go in v2 chat?? (probably )
Update:Just found dir(Datasets)
provides all attributes. Hope tha thelps someone
In 04_Multi-Label.ipynb
under Method 3: Custom get_items Functions
when I create the Dataloader from the Datablock - dls = planet.dataloaders(df)
i get the following error TypeError: unhashable type: 'list'
I’ll take a look today
How are you setting up the DataBlock @barnacl? And can you show me the full trace? (I won’t be at my computer for a few hours so Maybe we can figure it out here)
sure thing, (i haven’t changed anything from your notebook):
def _planet_items(x): return (
f'{planet_source}/train/'+x.image_name+'.jpg', x.tags.str.split())
planet = DataBlock(blocks=(ImageBlock, MultiCategoryBlock),
get_items = _planet_items,
splitter=RandomSplitter(),
batch_tfms=batch_tfms)
dls = planet.dataloaders(df)
the trace:
TypeError Traceback (most recent call last)
<ipython-input-7-278bfec03875> in <module>()
----> 1 dls = planet.dataloaders(df)
2 dls.show_batch(max_n=9, figsize=(12,9))
11 frames
/usr/local/lib/python3.6/dist-packages/fastai2/data/block.py in dataloaders(self, source, path, verbose, **kwargs)
89
90 def dataloaders(self, source, path='.', verbose=False, **kwargs):
---> 91 dsets = self.datasets(source)
92 kwargs = {**self.dls_kwargs, **kwargs, 'verbose': verbose}
93 return dsets.dataloaders(path=path, after_item=self.item_tfms, after_batch=self.batch_tfms, **kwargs)
/usr/local/lib/python3.6/dist-packages/fastai2/data/block.py in datasets(self, source, verbose)
86 splits = (self.splitter or noop)(items)
87 pv(f"{len(splits)} datasets of sizes {','.join([str(len(s)) for s in splits])}", verbose)
---> 88 return Datasets(items, tfms=self._combine_type_tfms(), splits=splits, dl_type=self.dl_type, n_inp=self.n_inp, verbose=verbose)
89
90 def dataloaders(self, source, path='.', verbose=False, **kwargs):
/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py in __init__(self, items, tfms, tls, n_inp, dl_type, **kwargs)
248 def __init__(self, items=None, tfms=None, tls=None, n_inp=None, dl_type=None, **kwargs):
249 super().__init__(dl_type=dl_type)
--> 250 self.tls = L(tls if tls else [TfmdLists(items, t, **kwargs) for t in L(ifnone(tfms,[None]))])
251 self.n_inp = (1 if len(self.tls)==1 else len(self.tls)-1) if n_inp is None else n_inp
252
/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py in <listcomp>(.0)
248 def __init__(self, items=None, tfms=None, tls=None, n_inp=None, dl_type=None, **kwargs):
249 super().__init__(dl_type=dl_type)
--> 250 self.tls = L(tls if tls else [TfmdLists(items, t, **kwargs) for t in L(ifnone(tfms,[None]))])
251 self.n_inp = (1 if len(self.tls)==1 else len(self.tls)-1) if n_inp is None else n_inp
252
/usr/local/lib/python3.6/dist-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
/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py in __init__(self, items, tfms, use_list, do_setup, as_item, split_idx, train_setup, splits, types, verbose)
189 if do_setup:
190 pv(f"Setting up {self.tfms}", verbose)
--> 191 self.setup(train_setup=train_setup)
192
193 def _new(self, items, **kwargs): return super()._new(items, tfms=self.tfms, do_setup=False, types=self.types, **kwargs)
/usr/local/lib/python3.6/dist-packages/fastai2/data/core.py in setup(self, train_setup)
202
203 def setup(self, train_setup=True):
--> 204 self.tfms.setup(self, train_setup)
205 if len(self) != 0:
206 x = super().__getitem__(0) if self.splits is None else super().__getitem__(self.splits[0])[0]
/usr/local/lib/python3.6/dist-packages/fastcore/transform.py in setup(self, items, train_setup)
171 tfms = self.fs[:]
172 self.fs.clear()
--> 173 for t in tfms: self.add(t,items, train_setup)
174
175 def add(self,t, items=None, train_setup=False):
/usr/local/lib/python3.6/dist-packages/fastcore/transform.py in add(self, t, items, train_setup)
174
175 def add(self,t, items=None, train_setup=False):
--> 176 t.setup(items, train_setup)
177 self.fs.append(t)
178
/usr/local/lib/python3.6/dist-packages/fastcore/transform.py in setup(self, items, train_setup)
66 def setup(self, items=None, train_setup=False):
67 train_setup = train_setup if self.train_setup is None else self.train_setup
---> 68 return self.setups(getattr(items, 'train', items) if train_setup else items)
69
70 def _call(self, fn, x, split_idx=None, **kwargs):
/usr/local/lib/python3.6/dist-packages/fastcore/dispatch.py in __call__(self, *args, **kwargs)
96 if not f: return args[0]
97 if self.inst is not None: f = MethodType(f, self.inst)
---> 98 return f(*args, **kwargs)
99
100 def __get__(self, inst, owner):
/usr/local/lib/python3.6/dist-packages/fastai2/data/transforms.py in setups(self, dsets)
200 if self.vocab is None:
201 vals = set()
--> 202 for b in dsets: vals = vals.union(set(b))
203 self.vocab = CategoryMap(list(vals), add_na=self.add_na)
204
TypeError: unhashable type: 'list'
From what I can see, essentially it can’t grab our vocab for some particular reason.
Aha! Sneaky update There is now a DataBlock.from_columns
function. So the fix is:
planet = DataBlock.from_columns(blocks=(ImageBlock, MultiCategoryBlock),
get_items = _planet_items,
splitter=RandomSplitter(),
batch_tfms=batch_tfms)
@barnacl
For anyone who wants to keep an eye (and in case I miss an update like I just did), I keep track of this notebook here:
I’ll update our notebook here in a moment
Not a problem! The notebook has been updated on our repo
can we go through dblock.summary(source)
next time. i don’t fully understand what the output means. i didn’t succeed in running mnist.summary(untar_data(URLs.MNIST_TINY))
from https://github.com/fastai/fastai2/blob/master/nbs/50_datablock_examples.ipynb. i get the following error
Setting-up type transforms pipelines
Collecting items from /root/.fastai/data/mnist_tiny
Found 1428 items
2 datasets of sizes 709,699
Setting up Pipeline: (#2) [Transform: True (object,object) -> noop ,Transform: True (bytes,object) -> create
(ndarray,object) -> create
(Tensor,object) -> create
(str,object) -> create
(Path,object) -> create ]
Setting up Pipeline: (#2) [Transform: True (object,object) -> parent_label ,Categorize: True (object,object) -> encodes (object,object) -> decodes]
Building one sample
Pipeline: (#2) [Transform: True (object,object) -> noop ,Transform: True (bytes,object) -> create
(ndarray,object) -> create
(Tensor,object) -> create
(str,object) -> create
(Path,object) -> create ]
starting from
/root/.fastai/data/mnist_tiny/train/3/8551.png
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-37-e3fa48cc8be2> in <module>()
----> 1 mnist.summary(untar_data(URLs.MNIST_TINY))
1 frames
/usr/local/lib/python3.6/dist-packages/fastai2/data/block.py in summary(self, source, bs, **kwargs)
124 dsets = self.datasets(source, verbose=True)
125 print("\nBuilding one sample")
--> 126 for tl in dsets.train.tls: _apply_pipeline(tl.tfms, dsets.train.items[0])
127 print(f"\nFinal sample: {dsets.train[0]}\n\n")
128
/usr/local/lib/python3.6/dist-packages/fastai2/data/block.py in _apply_pipeline(p, x)
109 print(f" {p}\n starting from\n {_short_repr(x)}")
110 for f in p.fs:
--> 111 name = f.name
112 try:
113 x = f(x)
AttributeError: 'Transform' object has no attribute 'name'
I’ll do my best to (I’m trying to understand that myself too! ) @barnacl I’d move that to the fastai2 chat and @ sgugger for assistance
Before you do @barnacl try doing a dev install of fastai2 and fastcore and see if it works that way
glad i took your advice and didn’t do @ sgugger it works on the dev install