How to use RandomSampler

Ubuntu 18.04 or Mac OS Catalina, Python 3.7, PyTorch 1.4.0

I try to sample from a dataset using predefined indices, SubsetRandomSampler works as expected, RandomSampler does not work as expected, I check the source code, and it seems RandomSampler is just using the length of the data_source argument and the samples has nothing to do with data_source, can anyone help me understand what is the meaning of the argument data_source?

Judging from the source code of RandomSampler, data_source is only there to provide the number of elements :frowning:. If u need to sample from some specific indexes, I guess writing your own Sampler would work, it’s not very hard.