You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
My own task or dataset (give details below)
Reproduction
I wanted to train a Roberta model for classification. However, during the computation of the loss for multi-label classification, the dimensions are mismatched. I found the problem in transformers/models/roberta/modeling_roberta.py:1229:
loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
The labels are flattened but the logits are formed to have dimensions (batch_size, num_labels). Slightly changing the line fixes the problem
loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1, self.num_labels))
Expected behavior
Compute the loss without the dimension mismatch
The text was updated successfully, but these errors were encountered:
System Info
transformers version 4.41.2, Windows 10
Who can help?
@ArthurZucker
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
I wanted to train a Roberta model for classification. However, during the computation of the loss for multi-label classification, the dimensions are mismatched. I found the problem in transformers/models/roberta/modeling_roberta.py:1229:
loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
The labels are flattened but the logits are formed to have dimensions (batch_size, num_labels). Slightly changing the line fixes the problem
loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1, self.num_labels))
Expected behavior
Compute the loss without the dimension mismatch
The text was updated successfully, but these errors were encountered: