ReplacementSampler¶
- class ReplacementSampler(dataset, batch_size=1, drop_last=False, num_samples=None, weights=None, world_size=None, rank=None, seed=None)[source]¶
Sample elements randomly with replacement.
- Parameters
dataset – dataset to sample from.
batch_size – batch size for batch method.
drop_last – set
Trueto drop the last incomplete batch, if the dataset size is not divisible by the batch size. IfFalseand the size of dataset is not divisible by the batch_size, then the last batch will be smaller. Default: Falsenum_samples – number of samples assigned to one rank.
weights – weights for sampling indices, it could be unnormalized weights.
world_size – number of ranks.
rank – rank id, non-negative interger within 0 and
world_size.seed – seed for random operators.