Spaces:
Sleeping
Sleeping
Update model.py
Browse files
model.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from transformers.models.roberta.modeling_roberta import *
|
2 |
|
3 |
|
@@ -87,7 +89,7 @@ class MRCQuestionAnswering(RobertaPreTrainedModel):
|
|
87 |
start_positions = start_positions.clamp(0, ignored_index)
|
88 |
end_positions = end_positions.clamp(0, ignored_index)
|
89 |
|
90 |
-
loss_fct = CrossEntropyLoss(ignore_index=ignored_index)
|
91 |
start_loss = loss_fct(start_logits, start_positions)
|
92 |
end_loss = loss_fct(end_logits, end_positions)
|
93 |
total_loss = (start_loss + end_loss) / 2
|
|
|
1 |
+
import torch
|
2 |
+
import torch.nn as nn
|
3 |
from transformers.models.roberta.modeling_roberta import *
|
4 |
|
5 |
|
|
|
89 |
start_positions = start_positions.clamp(0, ignored_index)
|
90 |
end_positions = end_positions.clamp(0, ignored_index)
|
91 |
|
92 |
+
loss_fct = nn.CrossEntropyLoss(ignore_index=ignored_index)
|
93 |
start_loss = loss_fct(start_logits, start_positions)
|
94 |
end_loss = loss_fct(end_logits, end_positions)
|
95 |
total_loss = (start_loss + end_loss) / 2
|