RepDistiller icon indicating copy to clipboard operation
RepDistiller copied to clipboard

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

Open Jiawen-huang opened this issue 5 years ago • 3 comments

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'

Jiawen-huang avatar Dec 25 '20 08:12 Jiawen-huang

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)

siihwanpark avatar Jan 02 '21 05:01 siihwanpark

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

NEUdeep avatar Jan 05 '21 02:01 NEUdeep

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

Harr7y avatar Nov 11 '21 09:11 Harr7y