MCPcopy Index your code
hub / github.com/HobbitLong/PyContrast / __init__

Method __init__

pycontrast/memory/mem_bank.py:95–105  ·  view source on GitHub ↗
(self, n_dim, n_data, K=65536, T=0.07, m=0.5)

Source from the content-addressed store, hash-verified

93class CMCMem(BaseMem):
94 """Memory bank for two modalities, e.g. in CMC"""
95 def __init__(self, n_dim, n_data, K=65536, T=0.07, m=0.5):
96 super(CMCMem, self).__init__(K, T, m)
97 # create sampler
98 self.multinomial = AliasMethod(torch.ones(n_data))
99 self.multinomial.cuda()
100
101 # create memory bank
102 self.register_buffer('memory_1', torch.randn(n_data, n_dim))
103 self.register_buffer('memory_2', torch.randn(n_data, n_dim))
104 self.memory_1 = F.normalize(self.memory_1)
105 self.memory_2 = F.normalize(self.memory_2)
106
107 def forward(self, x1, x2, y, x1_jig=None, x2_jig=None,
108 all_x1=None, all_x2=None, all_y=None):

Callers

nothing calls this directly

Calls 3

AliasMethodClass · 0.85
cudaMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected