This is a little bit late, but I hope this can help the others.
In case if you can’t use SubsetRandomSampler, here’s a manual solution for you. (The reason why we can’t use SubsetRandomSampler is because we also need other samplers and two of them won’t work together) You can refer to this question 48 where people get confused too.
If you look closely, the image paths and the associated labels are saved in dataset.samples from ImageFolder output. Therefore, you can do
dataset.samples = [dataset.samples[idx] for idx in your_list_of_interest]
dataset.targets = [dataset.targets[idx] for idx in your_list_of_interest]
dataset.targets = [dataset.targets[idx] for idx in your_list_of_interest]

to subsample
In your case, your_list_of_interest is range(100).