- Why
DataLoaderhas bothsampleras well asbatch_sampler? while there is already a sampler that istorch.utils.data.BatchSampler? does that mean I can pass BatchSampler only asbatch_samplerof DataLaoder? - If I want a
DistributedSamplerthat is also in batches/BatchSamplerand is random/RandomSamplerI will have no option to mix them!
bothDistributedSamplerandRandomSamplerwrap a dataset/data_source and onlyBatchSamplercan wrap one of them. - Even if we could mix them, what would be difference of
RandomSampler(BatchSampler(DistributedSampler(dataset)))andBatchSampler(RandomSampler(DistributedSampler(dataset))). - So I think I should use
sampler=DistributedSampler(dataset)and pass abatch_sizetoDataLoader(or usesampler=BatchSampler(DistributedSampler(dataset))). But how can I make it random?shuffleis mutually exclusive fromsamplerand I cannot mixRandomSamplerwithDistributedSampler.
Looking at the code DistributedSampler(RandomSampler(...)) is valid, dataset does not have to be a Dataset, it can be another Sampler because only len() matters that any Sampler provides.