scvi.core.data_loaders.ScviDataLoader

class scvi.core.data_loaders.ScviDataLoader(model, adata, shuffle=False, indices=None, use_cuda=True, batch_size=128, data_loader_kwargs={})[source]

Scvi Data Loader.

A ScviDataLoader instance is instantiated with a model and a gene_dataset, and as well as additional arguments that for Pytorch’s DataLoader. A subset of indices can be specified, for purposes such as splitting the data into train/test or labelled/unlabelled (for semi-supervised learning). Each trainer instance of the Trainer class can therefore have multiple ScviDataLoader instances to train a model. A ScviDataLoader instance also comes with methods to compute likelihood and other relevant training metrics.

Parameters
model

A model instance from class VAE, VAEC, SCANVI

gene_dataset

A gene_dataset instance like CortexDataset()

shuffle

Specifies if a RandomSampler or a SequentialSampler should be used

indices

Specifies how the data should be split with regards to train/test or labelled/unlabelled

use_cuda

Default: True

data_loader_kwargs

Keyword arguments to passed into the DataLoader

Attributes

indices

Returns the current dataloader indices used by the object.

n_cells

Returns the number of studied cells.

scvi_data_loader_type

Returns the dataloader class name.

Methods

accuracy()

elbo()

Returns the Evidence Lower Bound associated to the object.

marginal_ll([n_mc_samples])

Estimates the marginal likelihood of the object’s data.

reconstruction_error()

Returns the reconstruction error associated to the object.

sequential([batch_size])

Returns a copy of the object that iterate over the data sequentially.

to_cuda(tensors)

Converts dict of tensors to cuda.

update(data_loader_kwargs)

Updates the dataloader.

update_batch_size(batch_size)

update_sampler_indices(idx)

Updates the data loader indices.