MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / RandomSampler

Class RandomSampler

lib/utils/data/sampler.py:39–53  ·  view source on GitHub ↗

Samples elements randomly, without replacement. Arguments: data_source (Dataset): dataset to sample from

Source from the content-addressed store, hash-verified

37
38
39class RandomSampler(Sampler):
40 """Samples elements randomly, without replacement.
41
42 Arguments:
43 data_source (Dataset): dataset to sample from
44 """
45
46 def __init__(self, data_source):
47 self.data_source = data_source
48
49 def __iter__(self):
50 return iter(torch.randperm(len(self.data_source)).long())
51
52 def __len__(self):
53 return len(self.data_source)
54
55
56class SubsetRandomSampler(Sampler):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected