MCPcopy Create free account
hub / github.com/HobbitLong/PyContrast / get_shuffle_ids

Method get_shuffle_ids

pycontrast/networks/util.py:48–56  ·  view source on GitHub ↗
(self, bsz)

Source from the content-addressed store, hash-verified

46 return x
47
48 def get_shuffle_ids(self, bsz):
49 n_img = int(bsz / self.k)
50 rnd_ids = [torch.randperm(self.k) for i in range(n_img)]
51 rnd_ids = torch.cat(rnd_ids, dim=0)
52 base_ids = torch.arange(bsz)
53 base_ids = torch.div(base_ids, self.k).long()
54 base_ids = base_ids * self.k
55 shuffle_ids = rnd_ids + base_ids
56 return shuffle_ids

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected