SequentialSampler

class SequentialSampler(dataset, batch_size=1, drop_last=False, indices=None, world_size=None, rank=None)[source]

Sample elements sequentially.

Parameters
  • dataset – dataset to sample from.

  • batch_size – batch size for batch method.

  • drop_last – set True to drop the last incomplete batch, if the dataset size is not divisible by the batch size. If False and the size of dataset is not divisible by the batch_size, then the last batch will be smaller. Default: False

  • indices – indice of samples.

  • world_size – number of ranks.

  • rank – rank id, non-negative interger within 0 and world_size.

sample()[source]

Return a generator.

Return type

Iterator[Any]