fix sampler length
This commit is contained in:
parent
6ea681beeb
commit
5bd396712c
|
@ -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):
|
||||||
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):
|
||||||
|
|
Loading…
Reference in New Issue