Closed zhouzj1610 closed 1 year ago
TripletInBatchNegSoftmaxContrastLoss的forward函数中,labels如下: labels = torch.zeros(sim_matrix.size(0), dtype=torch.long, device=sim_matrix.device) loss = torch.nn.CrossEntropyLoss()(sim_matrix, labels)
为什么是torch.zeros,是不是应该是: labels = torch.arange(sim_matrix.size(0), dtype=torch.long, device=sim_matrix.device)
None
因为正例都是在 0 索引的位置,所以是 zeros
🐛 bug 说明
TripletInBatchNegSoftmaxContrastLoss的forward函数中,labels如下: labels = torch.zeros(sim_matrix.size(0), dtype=torch.long, device=sim_matrix.device) loss = torch.nn.CrossEntropyLoss()(sim_matrix, labels)
为什么是torch.zeros,是不是应该是: labels = torch.arange(sim_matrix.size(0), dtype=torch.long, device=sim_matrix.device)
Python Version
None