MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / __init__

Method __init__

datasets/sampler.py:61–76  ·  view source on GitHub ↗
(self, dataset, pad=False, consecutive_sample=False, permutation=False, num_replicas=None, rank=None)

Source from the content-addressed store, hash-verified

59 """
60
61 def __init__(self, dataset, pad=False, consecutive_sample=False, permutation=False, num_replicas=None, rank=None):
62 if num_replicas is None:
63 num_replicas = get_world_size()
64 if rank is None:
65 rank = get_rank()
66 self.dataset = dataset
67 self.num_replicas = num_replicas
68 self.rank = rank
69 self.epoch = 0
70 self.consecutive_sample = consecutive_sample
71 self.permutation = permutation
72 if pad:
73 self.num_samples = int(math.ceil(len(self.dataset) * 1.0 / self.num_replicas))
74 else:
75 self.num_samples = int(math.floor(len(self.dataset) * 1.0 / self.num_replicas))
76 self.total_size = self.num_samples * self.num_replicas
77
78 def __iter__(self):
79 # deterministically shuffle based on epoch

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected