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
03056730
Unverified
Commit
03056730
authored
Aug 30, 2021
by
Maxwell Forbes
Committed by
GitHub
Aug 30, 2021
Browse files
Fall back to `observed_batch_size` when the `dataloader` does not know the `batch_size`. (#13188)
parent
ce6add8e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
src/transformers/trainer.py
src/transformers/trainer.py
+3
-0
No files found.
src/transformers/trainer.py
View file @
03056730
...
@@ -2203,6 +2203,9 @@ class Trainer:
...
@@ -2203,6 +2203,9 @@ class Trainer:
observed_batch_size
=
find_batch_size
(
inputs
)
observed_batch_size
=
find_batch_size
(
inputs
)
if
observed_batch_size
is
not
None
:
if
observed_batch_size
is
not
None
:
observed_num_examples
+=
observed_batch_size
observed_num_examples
+=
observed_batch_size
# For batch samplers, batch_size is not known by the dataloader in advance.
if
batch_size
is
None
:
batch_size
=
observed_batch_size
# 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
)
...
...
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