Skip to content
Discussion options

You must be logged in to vote

Hey @YuShen1116,

Here is the pseudo code to get it working

from typing import List
import itertools
from pytorch_lightning.trainer.supporters import CombinedLoader
from pytorch_lightning.utilities.apply_func import apply_to_collection


class CyclingLoader(object):

    def __init__(self, combined_loaders: List[CombinedLoader]):
        self.combined_loaders = combined_loaders
        self._dataloader_idx_cycle = itertools.cycle(range(len(combined_loaders)))

    def __iter__(self):
        self._iterators = apply_to_collection(self.combined_loaders, CombinedLoader, iter)
        self._dataloader_idx_cycle_iter = iter(self._dataloader_idx_cycle)
        return self

    def __next__(self)…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@YuShen1116
Comment options

Answer selected by YuShen1116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment