Issue trying to index pandas dataframe via tensor scalar

Yes. I believe index is a tensor if you are using WeightedRandomSampler. You can always print out index to be sure. It should therefore be X = self.read_images(index.data)