cerebras.modelzoo.data.vision.utils.ShardedSampler#

class cerebras.modelzoo.data.vision.utils.ShardedSampler[source]#

Bases: torch.utils.data.Sampler

Modified from: https://pytorch.org/docs/stable/_modules/torch/utils/data/distributed.html#DistributedSampler Sampler that restricts data loading to a subset of the dataset.

Dataset is assumed to be of constant size.

Parameters
  • dataset (torch.utils.data.Dataset) – Dataset used for sampling.

  • mode (modes) – Instance of modes to indicate train or eval mode.

  • shuffle (bool, optional) – If True (default), sampler will shuffle the indices.

  • seed (int, optional) – Random seed used to shuffle the sampler if shuffle=True. This number should be identical across all processes in the distributed group. Default: 0.

  • drop_last (bool, optional) – If True, then the sampler will drop the tail of the data to make it evenly divisible across the number of replicas. If False, the sampler will add extra indices to make the data evenly divisible across the replicas. Default: False.

Methods

__init__(dataset, shuffle=True, seed=None, drop_last=False)[source]#
__call__(*args: Any, **kwargs: Any) Any#

Call self as a function.

static __new__(cls, *args: Any, **kwargs: Any) Any#