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

Class SubsetRandomSampler

lib/utils/data/sampler.py:56–70  ·  view source on GitHub ↗

Samples elements randomly from a given list of indices, without replacement. Arguments: indices (list): a list of indices

Source from the content-addressed store, hash-verified

54
55
56class SubsetRandomSampler(Sampler):
57 """Samples elements randomly from a given list of indices, without replacement.
58
59 Arguments:
60 indices (list): a list of indices
61 """
62
63 def __init__(self, indices):
64 self.indices = indices
65
66 def __iter__(self):
67 return (self.indices[i] for i in torch.randperm(len(self.indices)))
68
69 def __len__(self):
70 return len(self.indices)
71
72
73class WeightedRandomSampler(Sampler):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected