Dataloader : shuffle and sampler

Hi, every one,

I am using the sampler for loading the data with train_sampler and test_sampler, but with this method, I have to set the shuffle as False, is there some other way that i can use the train_sampler or test_sampler for data loading in the mean time I can keep the shuffle as True?

Thanks

1 Like

You would have to implement shuffling into your sampler.
Have a look at the implementation of RandomSampler.

4 Likes

@ptrblck If I use WeightedRandomSampler, does it mean that my data will be shuffled? Sorry it’s still not clear to me.

The samples will be drawn from your dataset using the provided weights, so you won’t get a specific order. In that sense your data will be shuffled.

5 Likes

@ptrblck I get it now. Thank you!

Hi @ptrblck, I am trying to apply sampler for two unbalanced datasets in single data loader(I merged two datasets). I have created an issue here.

Thanks!