MCPcopy Create free account
hub / github.com/TPCD/DCCL / __iter__

Method __iter__

project_utils/sampler.py:32–43  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

30 return self.num_samples * self.num_instances
31
32 def __iter__(self):
33 indices = torch.randperm(self.num_samples).tolist()
34 ret = []
35 for i in indices:
36 pid = self.pids[i]
37 t = self.index_dic[pid]
38 if len(t) >= self.num_instances:
39 t = np.random.choice(t, size=self.num_instances, replace=False)
40 else:
41 t = np.random.choice(t, size=self.num_instances, replace=True)
42 ret.extend(t)
43 return iter(ret)
44
45
46class RandomMultipleGallerySampler(Sampler):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected