Dataset formed by concatenating several map-style datasets end-to-end.
Sample i is fetched from the first child whose cumulative length
exceeds i, with the relative index translated accordingly.
Parameters
datasetslist of DatasetChild datasets, concatenated in order. Each child must implement
__len__ and __getitem__.Notes
A list of cumulative length offsets is maintained internally at construction time so that index resolution reduces to a single bounded scan (and could be upgraded to a binary search for O(log n) lookup on large child lists). Children are stored by reference; no per-sample copy is made.
Examples
>>> import lucid
>>> from lucid.utils.data import ConcatDataset, TensorDataset
>>> ds_a = TensorDataset(lucid.zeros(3, 2))
>>> ds_b = TensorDataset(lucid.ones(4, 2))
>>> ds_c = TensorDataset(lucid.ones(5, 2))
>>> combined = ConcatDataset([ds_a, ds_b, ds_c])
>>> len(combined) == len(ds_a) + len(ds_b) + len(ds_c)
TrueUsed by 1
Constructors
1Dunder methods
2Return the total length — sum of all child dataset lengths.