(self, prob1, prob2, simi)
| 143 | class 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 | |
| 155 | def PairEnum(x,mask=None): |
nothing calls this directly
no outgoing calls
no test coverage detected