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
f25457b2
Unverified
Commit
f25457b2
authored
Jun 30, 2022
by
Sylvain Gugger
Committed by
GitHub
Jun 30, 2022
Browse files
Fix number of examples for iterable dataset in distributed training (#17951)
parent
e4d25885
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
src/transformers/trainer.py
src/transformers/trainer.py
+4
-0
No files found.
src/transformers/trainer.py
View file @
f25457b2
...
...
@@ -1088,6 +1088,10 @@ class Trainer:
dataloader.dataset does not exist or has no length, estimates as best it can
"""
try
:
dataset
=
dataloader
.
dataset
# Special case for IterableDatasetShard, we need to dig deeper
if
isinstance
(
dataset
,
IterableDatasetShard
):
return
len
(
dataloader
.
dataset
.
dataset
)
return
len
(
dataloader
.
dataset
)
except
(
NameError
,
AttributeError
,
TypeError
):
# no dataset or length, estimate by length of dataloader
return
len
(
dataloader
)
*
self
.
args
.
per_device_train_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