Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove __len__ from CombinedStreamingDataset #19321

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/lightning/data/streaming/combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class CombinedStreamingDataset(IterableDataset):
"""The `CombinedStreamingDataset` enables to stream data from multiple StreamingDataset with the sampling ratio of
your choice.

Addtionally, the `CombinedStreamingDataset` keeps track of the number of
samples fetched to enable resumability of the datasets.
Addtionally, the `CombinedStreamingDataset` keeps track of the number of samples fetched to enable resumability
of the datasets.

Note that due to the random sampling, the number of samples returned from the iterator is variable and a function
of the given seed. The combined dataset will raise a StopIteration as soon as any of the datasets is exhausted.

"""

Expand All @@ -44,10 +47,6 @@ def __init__(

self._iterator: Optional[_CombinedDatasetIterator] = None

def __len__(self) -> int:
assert self._weights
return int(min([1 / w * len(d) for w, d in zip(self._weights, self._datasets) if w > 0]))

def __iter__(self) -> Iterator[Any]:
assert self._weights
self._iterator = _CombinedDatasetIterator(self._datasets, self._seed, self._weights)
Expand Down