(self, output1, output2, label)
| 18 | self.margin = margin |
| 19 | |
| 20 | def forward(self, output1, output2, label): |
| 21 | euclidean_distance = F.pairwise_distance(output1, output2, keepdim=True) |
| 22 | loss_contrastive = torch.mean((1-label) * torch.pow(euclidean_distance, 2) + |
| 23 | (label) * torch.pow(torch.clamp(self.margin - euclidean_distance, min=0.0), 2)) |
| 24 | return loss_contrastive |
| 25 | |
| 26 | |
| 27 | def init_weight(m): |
nothing calls this directly
no outgoing calls
no test coverage detected