I found the issue. But I am not able to find a way to get around it. I am calculating the weights on the subset indices, but I am passing the whole dataset to the train_loader. But I don’t think there is any way that is fast enough to get the subset of the train_set.