nip.utils.torch.FastForwardableBatchSampler#

class nip.utils.torch.FastForwardableBatchSampler(sampler: Sampler[int] | Iterable[int], batch_size: int, drop_last: bool, initial_skip: int = 0)[source]#

A batch sampler which can skip an initial number of items.

See the docs for PyTorch’s BatchSampler for details.

Parameters:
  • sampler (Sampler[int] | Iterable[int]) – Base sampler. Can be any iterable object

  • batch_size (int) – The size of the mini-batch

  • drop_last (bool) – If True, the sampler will drop the last batch if its size would be less than batch_size

  • initial_skip (int, default=0) – The number of items to skip at the start of the sampler.

Methods Summary

__init__(sampler, batch_size, drop_last[, ...])

__iter__()

Methods

__init__(sampler: Sampler[int] | Iterable[int], batch_size: int, drop_last: bool, initial_skip: int = 0)[source]#
__iter__() Iterator[list[int]][source]#