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

Method forward

project_utils/cluster_utils.py:145–152  ·  view source on GitHub ↗
(self, prob1, prob2, simi)

Source from the content-addressed store, hash-verified

143class BCE(nn.Module):
144 eps = 1e-7 # Avoid calculating log(0). Use the small value of float16.
145 def forward(self, prob1, prob2, simi):
146 # simi: 1->similar; -1->dissimilar; 0->unknown(ignore)
147 assert len(prob1)==len(prob2)==len(simi), 'Wrong input size:{0},{1},{2}'.format(str(len(prob1)),str(len(prob2)),str(len(simi)))
148 P = prob1.mul_(prob2)
149 P = P.sum(1)
150 P.mul_(simi).add_(simi.eq(-1).type_as(P))
151 neglogP = -P.add_(BCE.eps).log_()
152 return neglogP.mean()
153
154
155def PairEnum(x,mask=None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected