Unverified Commit b8682609 authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Double check for attribute num_examples (#12562)

* Double check for attribute

* Use right name
parent 0d2bffad
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment