MCPcopy Index your code
hub / github.com/OpenGVLab/InternVL / SubsetRandomSampler

Class SubsetRandomSampler

classification/dataset/samplers.py:16–35  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

14
15
16class SubsetRandomSampler(torch.utils.data.Sampler):
17 """Samples elements randomly from a given list of indices, without
18 replacement.
19
20 Arguments:
21 indices (sequence): a sequence of indices
22 """
23
24 def __init__(self, indices):
25 self.epoch = 0
26 self.indices = indices
27
28 def __iter__(self):
29 return (self.indices[i] for i in torch.randperm(len(self.indices)))
30
31 def __len__(self):
32 return len(self.indices)
33
34 def set_epoch(self, epoch):
35 self.epoch = epoch
36
37
38class NodeDistributedSampler(Sampler):

Callers 1

build_loaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected