Thank you @phillies, this fixed the problem for me
I have the same error, but in my case it is due to an error creating the ImageList
src = (ImageList.from_df(df.sample(n=200), path, folder='train', suffix='.jpeg')
.split_by_rand_pct()
.label_from_df(label_delim=',') # Error!
)
data = (src.transform(get_transforms(max_warp=0.), size=64).databunch().normalize())
learn = cnn_learner(data, models.resnet34, metrics=error_rate)
...
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'other'
the correct version works for me:
src = (ImageList.from_df(df.sample(n=200), path, folder='train', suffix='.jpeg')
.split_by_rand_pct()
.label_from_df(cols='level')
)
I’m also getting this error now, when trying to create a dataBunch
np.random.seed(44)
data = ImageDataBunch.from_folder(path,
train=".",
valid_pct=0.22,
ds_tfms=get_transforms(),
size=224,
num_workers=4,
bs=32).normalize(imagenet_stats)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/fastai/data_block.py in _check_kwargs(ds, tfms, **kwargs)
593 x = ds[0]
--> 594 try: x.apply_tfms(tfms, **kwargs)
595 except Exception as e:
10 frames
RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #3 'mat2' in call to _th_addmm_out
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/fastai/data_block.py in _check_kwargs(ds, tfms, **kwargs)
594 try: x.apply_tfms(tfms, **kwargs)
595 except Exception as e:
--> 596 raise Exception(f"It's not possible to apply those transforms to your dataset:\n {e}")
597
598 class LabelList(Dataset):
Exception: It's not possible to apply those transforms to your dataset:
Expected object of scalar type Float but got scalar type Double for argument #3 'mat2' in call to _th_addmm_out
Since my error is at the ImageDataBunch call, I don’t think the previous answers have solved for this. It’s weird, this same code was working fine a week ago.
Did you ever get a fix for this @f_izco? I’m facing the same thing now.
You need to upgrade your fastai to the latest version. This comes from a breaking change in PyTorch 1.5 and it was fixed recently.
Hello everyone,
Excited to start learning and found that I was attempting to do tubular_learn.fromcsv with a very simple dataset (Pass/Fail, or result, and time/Date) and I’m having the exact issue described inside of the Kagle environment. I attempt to upgrade fastai inside of the kaggle environment and it doesn’t seem to get past installing Numpy which is strange. So I figured I’d ask here for a solution that works in a kaggle environment. I really would like to give this a try, but i hit a roadblock that is rather frustrating and is populating the error in question. I even tried making a new accuracy by accuracy_1 which resulted in it having a NamingError for Rank0Tensor. Please, assist. Thank you.