I have a ConcatDataset and i want to know how many number of images per class so that i can apply WeightedRandomSampler
I don’t think there is a better generic solution than iterating over the dataset and recording the images per class. That said, you’ll be decoding all images once just for nothing, to a solution tailored to your dataset will be much more efficient.
i tried this way
counts= for d in data_list: print(len(np.unique(d.targets, return_counts=True))) counts.append(np.unique(d.targets, return_counts=True))