Solved,
in
md = ImageDataBunch.from_csv (path, img_path, csv_labels = csv, tfms = tfms, size = sz, bs = bs)
instead of tfms should be ds_tfms
Thank you
Hello all,
I’m just working on the 8th lesson with Fastai V1. Everything was fine until I tried to call
md.one_batch ()
then I got:
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 500 and 375 in dimension 2 at /opt/conda/conda-bld/pytorch-cpu_1544218667092/work/aten/src/TH/generic/THTensorMoreMath.cpp : 1,333
I do not know where I made a mistake and how to fix it
(below my notebook
sz=224
bs=64
csv='tmp/lrg.csv'
img_path='JPEGImages'
tfms = get_transforms()
md = ImageDataBunch.from_csv(path, img_path, csv_labels=csv, tfms=tfms, size=sz, bs=bs)
md.one_batch()
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-20-01435f9e1725> in <module>
----> 1 md.one_batch()
~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/basic_data.py in one_batch(self, ds_type, detach, denorm)
134 w = self.num_workers
135 self.num_workers = 0
--> 136 try: x,y = next(iter(dl))
137 finally: self.num_workers = w
138 if detach: x,y = to_detach(x),to_detach(y)
~/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/basic_data.py in __iter__(self)
68 def __iter__(self):
69 "Process and returns items from `DataLoader`."
---> 70 for b in self.dl:
71 y = b[1][0] if is_listy(b[1]) else b[1]
72 yield self.proc_batch(b)
~/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/utils/data/dataloader.py in __next__(self)
635 self.reorder_dict[idx] = batch
636 continue
--> 637 return self._process_next_batch(batch)
638
639 next = __next__ # Python 2 compatibility
~/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/utils/data/dataloader.py in _process_next_batch(self, batch)
656 self._put_indices()
657 if isinstance(batch, ExceptionWrapper):
--> 658 raise batch.exc_type(batch.exc_msg)
659 return batch
660
RuntimeError: Traceback (most recent call last):
File "/home/grzegorz/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/grzegorz/anaconda3/envs/fastai/lib/python3.7/site-packages/fastai/torch_core.py", line 99, in data_collate
return torch.utils.data.dataloader.default_collate(to_data(batch))
File "/home/grzegorz/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 232, in default_collate
return [default_collate(samples) for samples in transposed]
File "/home/grzegorz/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 232, in <listcomp>
return [default_collate(samples) for samples in transposed]
File "/home/grzegorz/anaconda3/envs/fastai/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 209, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 375 and 288 in dimension 2 at /opt/conda/conda-bld/pytorch-cpu_1544218667092/work/aten/src/TH/generic/THTensorMoreMath.cpp:1333
thank you in advance