thsolver.sampler

The samplers in this module provide endless iteration for training and testing without rebuilding the dataloader every epoch.

class InfSampler(dataset: Dataset, shuffle: bool = True)[source]

An infinite sampler that cycles through dataset indices.

Parameters:
  • dataset (Dataset) – The dataset to sample from.

  • shuffle (bool) – If True, shuffles the sample order between cycles.

reset_sampler()[source]

Resets the sampled index order for the next pass over the dataset.

class DistributedInfSampler(dataset: Dataset, shuffle: bool = True)[source]

An infinite sampler for distributed data parallel training.

Parameters:
  • dataset (Dataset) – The dataset to sample from.

  • shuffle (bool) – If True, shuffles the sample order between cycles.

reset_sampler()[source]

Rebuilds the local rank indices from the base distributed sampler.