'Tensor' object has no attribute 'deepcopy'
surya81 opened this issue · 5 comments
surya81 commented
Chapter 4
Data_augmentation_with_CNN
**Training DataLoader is Generating error by 'Tensor' object has no attribute 'deepcopy'
19valentin99 commented
just encountered the same error as you, in the beginning I thought that I made a mistake but after running the colab file, I found that the error was not my fault;
If i find a solution, I will mention it here.
So far, found this: https://www.kaggle.com/questions-and-answers/391038
and that the problem occurs in the augmentable library: C:\Users\username\anaconda3\envs\torch\Lib\site-packages\imgaug\augmentables\utils.py (line 19)
andysingal commented
Here is what i did to fix the error:
class FMNISTDataset(Dataset):
def __init__(self, x, y, aug=None):
self.x = x
self.y = y
self.aug = aug
def __getitem__(self, ix):
x, y = self.x[ix], self.y[ix]
if self.aug:
x = self.aug.augment_image(x.numpy())
x = torch.tensor(x).unsqueeze(0).float() / 255.0
y = torch.tensor(y).long()
return x, y
def __len__(self):
return len(self.x)