RuntimeError: Expected object of scalar type Double but got scalar type Long for sequence element 1 in sequence argument at position #1 'tensors'

Convert your data to float tensors should solve it:
i.e

dtype = torch.cuda.FloatTensor if torch.cuda.is_available() else torch.FloatTensor
for i, data in enumerate(dataloader):
    data['image'] = data['image'].type(dtype)
    data['label'] = data['label'].type(dtype) #Comment this line if it is a classification problem
    print(i, data['image'].size(), data['label'].size())
3 Likes