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
a7d21318
Unverified
Commit
a7d21318
authored
Jul 21, 2023
by
Sylvain Gugger
Committed by
GitHub
Jul 21, 2023
Browse files
Use main_input_name for include_inputs_for_metrics (#24993)
parent
a6484c89
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/transformers/trainer.py
src/transformers/trainer.py
+4
-2
No files found.
src/transformers/trainer.py
View file @
a7d21318
...
@@ -3121,7 +3121,8 @@ class Trainer:
...
@@ -3121,7 +3121,8 @@ class Trainer:
# Prediction step
# Prediction step
loss
,
logits
,
labels
=
self
.
prediction_step
(
model
,
inputs
,
prediction_loss_only
,
ignore_keys
=
ignore_keys
)
loss
,
logits
,
labels
=
self
.
prediction_step
(
model
,
inputs
,
prediction_loss_only
,
ignore_keys
=
ignore_keys
)
inputs_decode
=
self
.
_prepare_input
(
inputs
[
"input_ids"
])
if
args
.
include_inputs_for_metrics
else
None
main_input_name
=
getattr
(
self
.
model
,
"main_input_name"
,
"input_ids"
)
inputs_decode
=
self
.
_prepare_input
(
inputs
[
main_input_name
])
if
args
.
include_inputs_for_metrics
else
None
if
is_torch_tpu_available
():
if
is_torch_tpu_available
():
xm
.
mark_step
()
xm
.
mark_step
()
...
@@ -3674,7 +3675,8 @@ class Trainer:
...
@@ -3674,7 +3675,8 @@ class Trainer:
for
step
,
inputs
in
enumerate
(
dataloader
):
for
step
,
inputs
in
enumerate
(
dataloader
):
loss
,
logits
,
labels
=
self
.
prediction_step
(
model
,
inputs
,
prediction_loss_only
,
ignore_keys
=
ignore_keys
)
loss
,
logits
,
labels
=
self
.
prediction_step
(
model
,
inputs
,
prediction_loss_only
,
ignore_keys
=
ignore_keys
)
inputs_decode
=
self
.
_prepare_input
(
inputs
[
"input_ids"
])
if
args
.
include_inputs_for_metrics
else
None
main_input_name
=
getattr
(
self
.
model
,
"main_input_name"
,
"input_ids"
)
inputs_decode
=
self
.
_prepare_input
(
inputs
[
main_input_name
])
if
args
.
include_inputs_for_metrics
else
None
if
loss
is
not
None
:
if
loss
is
not
None
:
losses
=
loss
.
repeat
(
batch_size
)
losses
=
loss
.
repeat
(
batch_size
)
...
...
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