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
b8682609
Unverified
Commit
b8682609
authored
Jul 07, 2021
by
Sylvain Gugger
Committed by
GitHub
Jul 07, 2021
Browse files
Double check for attribute num_examples (#12562)
* Double check for attribute * Use right name
parent
0d2bffad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
src/transformers/trainer.py
src/transformers/trainer.py
+3
-1
No files found.
src/transformers/trainer.py
View file @
b8682609
...
...
@@ -2245,7 +2245,9 @@ class Trainer:
# Number of samples
if
not
isinstance
(
eval_dataset
,
IterableDataset
):
num_samples
=
len
(
eval_dataset
)
elif
isinstance
(
eval_dataset
,
IterableDatasetShard
):
# The instance check is weird and does not actually check for the type, but whether the dataset has the right
# methods. Therefore we need to make sure it also has the attribute.
elif
isinstance
(
eval_dataset
,
IterableDatasetShard
)
and
hasattr
(
eval_dataset
,
"num_examples"
):
num_samples
=
eval_dataset
.
num_examples
else
:
num_samples
=
observed_num_examples
...
...
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