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

AttributeError: 'CIFAR100InstanceSample' object has no attribute 'train_data' #38

Open
Jiawen-huang opened this issue Dec 25, 2020 · 3 comments

Comments

@Jiawen-huang
Copy link

I run your code:python train_student.py --path_t ./save/models/resnet32x4_vanilla/ckpt_epoch_240.pth --distill crd --model_s resnet8x4 -a 0 -b 0.8 --trial 1
but Encounter an error:

....../RepDistiller/dataset/cifar100.py", line 124, in init
num_samples = len(self.train_data)

AttributeError: 'CIFAR100InstanceSample' object has no attribute 'train_data'

@siihwanpark
Copy link

This issue is caused by the version of pyTorch. As version updated, the source code of torchvision.datasets.CIFAR100 also has been updated. This issue can be resolved simply replace datasets.CIFAR100 by source code from [here].(https://pytorch.org/docs/0.4.0/_modules/torchvision/datasets/cifar.html#CIFAR10)

@NEUdeep
Copy link

NEUdeep commented Jan 5, 2021

just like: img, target = self.data[index], self.targets[index] for 1.7.0

@Harr7y
Copy link

Harr7y commented Nov 11, 2021

torch 1.7.0 It works.

  1. in dataset/cifar100.py
    replace all the "self.train_data" and "self.test_data" with "self. data" ; "self.train_labels" and "self.test_labels" -> "self.targets"
  2. helper/util.py line:55
    replace "view(-1)" with "reshape(-1)"

More details in the definition of torchvision/datasets/cifar.py: class CIFAR10

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

No branches or pull requests

4 participants