scvi.external.contrastivevi.ContrastiveDataLoader#
- class scvi.external.contrastivevi.ContrastiveDataLoader(adata_manager, background_indices, target_indices, shuffle=False, batch_size=128, data_and_attributes=None, drop_last=False, distributed_sampler=False, load_sparse_tensor=False, **data_loader_kwargs)[source]#
Bases:
ConcatDataLoaderDataloader to load background and target data for contrastive analysis.
Each iteration of the dataloader returns a dictionary containing background and target data points, indexed by “background” and “target”, respectively.
- Parameters:
adata_manager (
AnnDataManager) –AnnDataManagerobject that has been created viasetup_anndata.background_indices (
list[int]) – Indices for background samples in the adata.target_indices (
list[int]) – Indices for target samples in the adata.shuffle (
bool(default:False)) – Whether the data should be shuffled.batch_size (
int(default:128)) – Mini-batch size to load for background and target data.data_and_attributes (
dict|None(default:None)) – Dictionary with keys representing keys in data registry (adata_manager.data_registry) and value equal to desired numpy loading type (later made into torch tensor). IfNone, defaults to all registered data.drop_last (
bool|int(default:False)) – Ifint, drops the last batch if its length is less thandrop_last. Ifdrop_last == True, drops last non-full batch. Ifdrop_last == False, iterate over all batches.distributed_sampler (
bool(default:False)) –EXPERIMENTALWhether to useBatchDistributedSampleras the sampler. If True, sampler must be None. Not applicable here.load_sparse_tensor (
bool(default:False)) –EXPERIMENTALIfTrue, loads data with sparse CSR or CSC layout as aTensorwith the same layout. Can lead to speedups in data transfers to GPUs, depending on the sparsity of the data. Not applicable here.**data_loader_kwargs (Keyword arguments for torch.utils.data.DataLoader.)
Attributes table#
Methods table#
Attributes#
- ContrastiveDataLoader.dataset: Dataset[_T_co]#
- ContrastiveDataLoader.batch_size: int | None#
- ContrastiveDataLoader.num_workers: int#
- ContrastiveDataLoader.pin_memory: bool#
- ContrastiveDataLoader.drop_last: bool#
- ContrastiveDataLoader.timeout: float#
- ContrastiveDataLoader.sampler: Sampler | Iterable#
- ContrastiveDataLoader.pin_memory_device: str#
- ContrastiveDataLoader.prefetch_factor: int | None#