HobbitLong / RepDistiller

[ICLR 2020] Contrastive Representation Distillation (CRD), and benchmark of recent knowledge distillation methods
BSD 2-Clause "Simplified" License
2.12k stars 391 forks source link

AttributeError: 'CIFAR100Instance' object has no attribute 'train_data' #4

Closed LiqunChen0606 closed 4 years ago

LiqunChen0606 commented 4 years ago

Thanks for your impressive work!

I try to reproduce the results from your paper, but when I test the code (i.e. cmd python train_student.py --path_t ./save/models/resnet32x4_vanilla/ckpt_epoch_240.pth --distill kd --model_s resnet8x4 -r 0.1 -a 0.9 -b 0 --trial 1), it shows:

File "~/work/RepDistiller/dataset/cifar100.py", line 44, in getitem img, target = self.train_data[index], self.train_labels[index] AttributeError: 'CIFAR100Instance' object has no attribute 'train_data'

By the way, my environment: Ubuntu 18.01, Python 3.6, Pytorch 1.2, torchvision 0.4.1, I also tested on Pytorch 0.4.0, still same issue

Could you please help me with this?

Thanks

HobbitLong commented 4 years ago

Hi @LiqunChen0606 ,

It sounds like your datasets.CIFAR100 object does not have the train_data attribute, which might relate to torchvision.

How about switching torchvision version back to version of 0.2.1?

=== update: for torchvision 0.4.1, you might want to use self.data and self.targets instead. See here

LiqunChen0606 commented 4 years ago

Thanks very much! Problem solved