提交 5bd39671 编写于 作者: C chenfeiyu

fix sampler length

上级 6ea681be
...@@ -39,18 +39,13 @@ class DataCargo(object): ...@@ -39,18 +39,13 @@ class DataCargo(object):
@property @property
def _index_sampler(self): 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: if self._auto_collation:
return self.batch_sampler return self.batch_sampler
else: else:
return self.sampler return self.sampler
def __len__(self): def __len__(self):
return len(self._index_sampler) # with iterable-style dataset, this will error return len(self._index_sampler)
class DataIterator(object): class DataIterator(object):
def __init__(self, loader): def __init__(self, loader):
......
...@@ -63,7 +63,7 @@ class RandomSampler(Sampler): ...@@ -63,7 +63,7 @@ class RandomSampler(Sampler):
return iter(np.random.permutation(n).tolist()) return iter(np.random.permutation(n).tolist())
def __len__(self): def __len__(self):
return len(self.data_source) return self.num_samples
class SubsetRandomSampler(Sampler): class SubsetRandomSampler(Sampler):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册