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
e823d819
Unverified
Commit
e823d819
authored
Oct 30, 2021
by
Haram Lee
Committed by
GitHub
Oct 29, 2021
Browse files
Add a condition for checking labels (#14211)
parent
b3385963
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
src/transformers/trainer_seq2seq.py
src/transformers/trainer_seq2seq.py
+6
-3
No files found.
src/transformers/trainer_seq2seq.py
View file @
e823d819
...
...
@@ -196,9 +196,12 @@ class Seq2SeqTrainer(Trainer):
if
self
.
args
.
prediction_loss_only
:
return
(
loss
,
None
,
None
)
if
has_labels
:
labels
=
inputs
[
"labels"
]
if
labels
.
shape
[
-
1
]
<
gen_kwargs
[
"max_length"
]:
labels
=
self
.
_pad_tensors_to_max_len
(
labels
,
gen_kwargs
[
"max_length"
])
else
:
labels
=
None
return
(
loss
,
generated_tokens
,
labels
)
...
...
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