facebookresearch / deepcluster

Deep Clustering for Unsupervised Learning of Visual Features
Other
1.67k stars 325 forks source link

image_list #7

Closed cuicanyu closed 5 years ago

cuicanyu commented 5 years ago

When I running the unsupervised training on cifar100, there is a problem: Traceback (most recent call last): File "main.py", line 323, in main() File "main.py", line 161, in main deepcluster.images_lists) File "/home/deepcluster-master/util.py", line 59, in init self.indexes = self.generate_indexes_epoch() File "/home/deepcluster-master/util.py", line 69, in generate_indexes_epoch replace=(len(self.images_lists[i]) <= size_per_pseudolabel) File "mtrand.pyx", line 1126, in mtrand.RandomState.choice ValueError: a must be non-empty I want to know how to deal with the image_list. Should I create one for cifar100?

mathildecaron31 commented 5 years ago

Hi, Thank you for your interest! The ImageNet class has for attribute a list imgs of (image path, class_index) tuples. On the other hand, the default CIFAR100 class has for attributes a list of paths (data) and a list of targets (targets). Therefore, you need to change the class defining CIFAR100 dataset to make it similar to the ImageNet one. To do so, you can write your own class inheriting from torch.utils.data.Dataset and containing a list imgs of (image path, class_index) tuples. For example you could do: self.imgs = [(self.data[i], self.targets[i]) for i in range(len(self.data))]

cuicanyu commented 5 years ago

Thanks a lot!

xiaxiaoshui222 commented 3 years ago

Hello, have you successfully reproduced this code with cifar data set? What is the clustering result? Looking forward to your answer, thank you very much!