Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
3be2d048
"vscode:/vscode.git/clone" did not exist on "3c6035aa8ad5c429299630f8c6f673896fbd7b16"
Unverified
Commit
3be2d048
authored
Aug 07, 2020
by
idoh
Committed by
GitHub
Aug 07, 2020
Browse files
fix consistency CrossEntropyLoss in modeling_bart (#6265)
parent
c72f9c90
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
src/transformers/modeling_bart.py
src/transformers/modeling_bart.py
+3
-2
No files found.
src/transformers/modeling_bart.py
View file @
3be2d048
...
...
@@ -1040,7 +1040,7 @@ class BartForConditionalGeneration(PretrainedBartModel):
masked_lm_loss
=
None
if
labels
is
not
None
:
loss_fct
=
nn
.
CrossEntropyLoss
()
loss_fct
=
CrossEntropyLoss
()
# TODO(SS): do we need to ignore pad tokens in labels?
masked_lm_loss
=
loss_fct
(
lm_logits
.
view
(
-
1
,
self
.
config
.
vocab_size
),
labels
.
view
(
-
1
))
...
...
@@ -1179,7 +1179,8 @@ class BartForSequenceClassification(PretrainedBartModel):
loss
=
None
if
labels
is
not
None
:
loss
=
F
.
cross_entropy
(
logits
.
view
(
-
1
,
self
.
config
.
num_labels
),
labels
.
view
(
-
1
))
loss_fct
=
CrossEntropyLoss
()
loss
=
loss_fct
(
logits
.
view
(
-
1
,
self
.
config
.
num_labels
),
labels
.
view
(
-
1
))
if
not
return_dict
:
output
=
(
logits
,)
+
outputs
[
1
:]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment