Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Tensor' object has no attribute 'deepcopy' #62

Open
surya81 opened this issue Jan 10, 2023 · 5 comments
Open

'Tensor' object has no attribute 'deepcopy' #62

surya81 opened this issue Jan 10, 2023 · 5 comments

Comments

@surya81
Copy link

surya81 commented Jan 10, 2023

Chapter 4

Data_augmentation_with_CNN

**Training DataLoader is Generating error by 'Tensor' object has no attribute 'deepcopy'

@19valentin99
Copy link

19valentin99 commented Mar 12, 2023

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
Copy link

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)

@GustaFTW
Copy link

Hi @andysingal

Can you post the whole code?
I tried your fix but still doesn't work, where is the collate_fn()? it was supposed to be inside the FMNISTDataset class, right?
I'd appreciate if you could help me.

@Camaltra
Copy link

Camaltra commented Sep 2, 2023

Hi! I actually re-open an issue about this problem, and give the solution to it 🙏
#75

@andysingal
Copy link

Hi @andysingal

Can you post the whole code? I tried your fix but still doesn't work, where is the collate_fn()? it was supposed to be inside the FMNISTDataset class, right? I'd appreciate if you could help me.

I hope the issue is resolved... Thanks @Camaltra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants