BatchSampler

class BatchSampler(index, batch_size, n_epochs=1, shuffle=False, drop_incomplete=False, seed=None)[source]

Get next batch of indices.

Parameters
  • batch_size (int) – Size of target batch.

  • n_epochs (int or None) – Maximal number of epochs. If None then loops are infinitely. Default to 1.

  • suffle (bool) – Shuffle indices after each epoch. Default to False.

  • drop_incomplete (bool) – Defines handling of incomplete batches in the end of epochs. If drop_incomplete is False we complete the batch with items from the beginning of the current epoch and return incomplete batch if current epoch is the last epoch. If drop_incomplete is True we go to the next epoch. Default to False.

Returns

index – Next indices.

Return type

index

property indices

Indices to sample from.

property params

Sampler parameters.

reset()[source]

Reset epochs counter to 0.