Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions swift/plugin/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def infonce_loss(outputs, labels, loss_scale=None, num_items_in_batch=None, **kw
similarity_matrix = torch.cat(logits_list, dim=1)
# temperature scaling and CE
similarity_matrix = similarity_matrix / temperature
loss = nn.CrossEntropyLoss()(similarity_matrix, labels) / world_size # avoid duplicate
loss = nn.CrossEntropyLoss()(similarity_matrix, labels)
else:
all_tensors = []
for tensor in split_tensors:
Expand Down Expand Up @@ -499,7 +499,6 @@ def infonce_loss(outputs, labels, loss_scale=None, num_items_in_batch=None, **kw
# next positive is neg+1
length += tensor.size(0) - 1
loss /= len(split_tensors)
loss /= world_size # avoid duplicate
return loss


Expand Down
Loading