wangyuxinwhy / uniem

unified embedding model
Apache License 2.0
826 stars 64 forks source link

TripletInBatchNegSoftmaxContrastLoss的forward函数中的labels有问题 #99

Closed zhouzj1610 closed 1 year ago

zhouzj1610 commented 1 year ago

🐛 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

wangyuxinwhy commented 1 year ago

因为正例都是在 0 索引的位置,所以是 zeros