fix multi-gpu squad loss
This commit is contained in:
@@ -455,6 +455,8 @@ class BertForQuestionAnswering(nn.Module):
|
||||
end_logits = end_logits.squeeze(-1)
|
||||
|
||||
if start_positions is not None and end_positions is not None:
|
||||
start_positions = start_positions.squeeze(-1) # If we are on multi-GPU, split add a dimension
|
||||
end_positions = end_positions.squeeze(-1)
|
||||
loss_fct = CrossEntropyLoss()
|
||||
start_loss = loss_fct(start_logits, start_positions)
|
||||
end_loss = loss_fct(end_logits, end_positions)
|
||||
|
||||
Reference in New Issue
Block a user