ConcatDataset#
- class ConcatDataset(datasets, loop=1)[source]#
Bases:
DatasetConcatenate several configured datasets into a single index space.
Builds each child dataset from its config and flattens them into a shared index of
(dataset_index, local_index)pairs, so a single sampler can draw from all of them. Items pass through unchanged from the owning child, so the emitted keys (coord,segment,instance,offsetafter collation, …) are whatever the children emit. Registered asConcatDataset– use astypeunderdata.train/data.val/data.test.- Parameters:
datasets (list[dict]) – List of child dataset configs, each built with
build_dataset().loop (int) – Epoch multiplier applied to the concatenated length. Also consumed by
MultiDatasetDataloaderas the main-dataset epoch multiplier; per-childloopvalues can act as sampling ratios when mixed batches are built. Defaults to1.
Example
>>> from pimm.datasets.builder import build_dataset >>> ds = build_dataset(dict(type="ConcatDataset", datasets=[ ... dict(type="PILArNetH5Dataset", revision="v2", split="train", transform=[]), ... dict(type="PILArNetH5Dataset", revision="v2", split="val", transform=[]), ... ])) >>> len(ds) # sum of child lengths (x loop) 1234567 >>> sample = ds[0] # item passes through unchanged from the owning child >>> # keys are whatever that child emits (here PILArNet: coord, energy, >>> # segment_motif, instance_particle, name, split, ...)