spdl.source.utils.repeat_source

repeat_source(src: Iterable[T] | IterableWithShuffle[T], /, epoch: int = 0) Iterator[T][source]

Convert an iterable into an infinite iterator with optional shuffling.

Roughly equivalent to the following code snippet.

while True:
    yield from src

    epoch += 1
    if hasattr(src, "shuffle"):
        src.shuffle(seed=epoch)
Parameters:
  • src – The source to repeat.

  • epoch – The epoch number to start with.