cellmap_data.CellMapDataLoader#
- class cellmap_data.CellMapDataLoader(dataset: CellMapMultiDataset | CellMapDataset | Subset | CellMapDatasetWriter, classes: Iterable[str], batch_size: int = 1, num_workers: int = 0, weighted_sampler: bool = False, sampler: Sampler | Callable | None = None, is_train: bool = True, rng: Generator | None = None, **kwargs)[source]#
Initialize the CellMapDataLoader
- Parameters:
dataset (CellMapMultiDataset | CellMapDataset | CellMapSubset) – The dataset to load.
classes (Iterable[str]) – The classes to load.
batch_size (int) – The batch size.
num_workers (int) – The number of workers to use.
weighted_sampler (bool) – Whether to use a weighted sampler. Defaults to False.
sampler (Sampler | Callable | None) – The sampler to use.
is_train (bool) – Whether the data is for training and thus should be shuffled.
rng (Optional[torch.Generator]) – The random number generator to use.
**kwargs – Additional arguments to pass to the DataLoader.
- __init__(dataset: CellMapMultiDataset | CellMapDataset | Subset | CellMapDatasetWriter, classes: Iterable[str], batch_size: int = 1, num_workers: int = 0, weighted_sampler: bool = False, sampler: Sampler | Callable | None = None, is_train: bool = True, rng: Generator | None = None, **kwargs)[source]#
Initialize the CellMapDataLoader
- Parameters:
dataset (CellMapMultiDataset | CellMapDataset | CellMapSubset) – The dataset to load.
classes (Iterable[str]) – The classes to load.
batch_size (int) – The batch size.
num_workers (int) – The number of workers to use.
weighted_sampler (bool) – Whether to use a weighted sampler. Defaults to False.
sampler (Sampler | Callable | None) – The sampler to use.
is_train (bool) – Whether the data is for training and thus should be shuffled.
rng (Optional[torch.Generator]) – The random number generator to use.
**kwargs – Additional arguments to pass to the DataLoader.
Methods
__init__
(dataset, classes[, batch_size, ...])Initialize the CellMapDataLoader
collate_fn
(batch)Combine a list of dictionaries from different sources into a single dictionary for output.
refresh
()If the sampler is a Callable, refresh the DataLoader with the current sampler.