mirror of
https://github.com/huggingface/pytorch-image-models.git
synced 2025-06-03 15:01:08 +08:00
Fix MultiEpochsDataLoader when there's no batching
This commit is contained in:
parent
6e9d6172c8
commit
feaa3abc51
@ -230,12 +230,15 @@ class MultiEpochsDataLoader(torch.utils.data.DataLoader):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self._DataLoader__initialized = False
|
||||
self.batch_sampler = _RepeatSampler(self.batch_sampler)
|
||||
if self.batch_sampler is None:
|
||||
self.sampler = RepeatSampler(self.sampler)
|
||||
else:
|
||||
self.batch_sampler = RepeatSampler(self.batch_sampler)
|
||||
self._DataLoader__initialized = True
|
||||
self.iterator = super().__iter__()
|
||||
|
||||
def __len__(self):
|
||||
return len(self.batch_sampler.sampler)
|
||||
return len(self.sampler) if self.batch_sampler is None else len(self.batch_sampler.sampler)
|
||||
|
||||
def __iter__(self):
|
||||
for i in range(len(self)):
|
||||
|
Loading…
x
Reference in New Issue
Block a user