make DataIterator compatible for python 2
This commit is contained in:
parent
25883dcd3e
commit
78582dbecd
|
@ -1,3 +1,4 @@
|
||||||
|
import six
|
||||||
from .sampler import SequentialSampler, RandomSampler, BatchSampler
|
from .sampler import SequentialSampler, RandomSampler, BatchSampler
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +85,11 @@ class DataIterator(object):
|
||||||
return minibatch
|
return minibatch
|
||||||
|
|
||||||
def _next_index(self):
|
def _next_index(self):
|
||||||
return next(self._sampler_iter)
|
if six.PY3:
|
||||||
|
return next(self._sampler_iter)
|
||||||
|
else:
|
||||||
|
# six.PY2
|
||||||
|
return self._sampler_iter.next()
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self._index_sampler)
|
return len(self._index_sampler)
|
||||||
|
|
Loading…
Reference in New Issue