From 5bd396712c2c0eae87ceb197ba75ded5c8f274dc Mon Sep 17 00:00:00 2001 From: chenfeiyu Date: Mon, 25 Nov 2019 10:47:31 +0000 Subject: [PATCH] fix sampler length --- parakeet/data/datacargo.py | 7 +------ parakeet/data/sampler.py | 2 +- {tests => test}/test_ljspeech.py | 0 {tests => test}/test_vctk.py | 0 4 files changed, 2 insertions(+), 7 deletions(-) rename {tests => test}/test_ljspeech.py (100%) rename {tests => test}/test_vctk.py (100%) diff --git a/parakeet/data/datacargo.py b/parakeet/data/datacargo.py index 07f9d37..da6bc9a 100644 --- a/parakeet/data/datacargo.py +++ b/parakeet/data/datacargo.py @@ -39,18 +39,13 @@ class DataCargo(object): @property def _index_sampler(self): - # The actual sampler used for generating indices for `_DatasetFetcher` - # (see _utils/fetch.py) to read data at each time. This would be - # `.batch_sampler` if in auto-collation mode, and `.sampler` otherwise. - # We can't change `.sampler` and `.batch_sampler` attributes for BC - # reasons. if self._auto_collation: return self.batch_sampler else: return self.sampler def __len__(self): - return len(self._index_sampler) # with iterable-style dataset, this will error + return len(self._index_sampler) class DataIterator(object): def __init__(self, loader): diff --git a/parakeet/data/sampler.py b/parakeet/data/sampler.py index ff6d5d7..097cc03 100644 --- a/parakeet/data/sampler.py +++ b/parakeet/data/sampler.py @@ -63,7 +63,7 @@ class RandomSampler(Sampler): return iter(np.random.permutation(n).tolist()) def __len__(self): - return len(self.data_source) + return self.num_samples class SubsetRandomSampler(Sampler): diff --git a/tests/test_ljspeech.py b/test/test_ljspeech.py similarity index 100% rename from tests/test_ljspeech.py rename to test/test_ljspeech.py diff --git a/tests/test_vctk.py b/test/test_vctk.py similarity index 100% rename from tests/test_vctk.py rename to test/test_vctk.py