!2059 fix SubsetSampler error

Merge pull request !2059 from yanghaitao/yht_fix_subset_samplers
This commit is contained in:
mindspore-ci-bot 2020-06-12 20:05:06 +08:00 committed by Gitee
commit 9282b9473d
1 changed files with 3 additions and 0 deletions

View File

@ -506,6 +506,9 @@ class SubsetRandomSampler(BuiltinSampler):
def get_num_samples(self):
num_samples = super().get_num_samples()
if num_samples is None:
return len(self.indices)
return min(len(self.indices), num_samples)