mypackage.MyModel

class mypackage.MyModel(adata, n_hidden=128, n_latent=10, n_layers=1, **model_kwargs)[source]

Skeleton for an scvi-tools model.

Please use this skeleton to create new models.

Parameters
adata : AnnDataAnnData

AnnData object that has been registered via setup_anndata().

n_hidden : intint (default: 128)

Number of nodes per hidden layer.

n_latent : intint (default: 10)

Dimensionality of the latent space.

n_layers : intint (default: 1)

Number of hidden layers used for encoder and decoder NNs.

**model_kwargs

Keyword args for MyModule

Examples

>>> adata = anndata.read_h5ad(path_to_anndata)
>>> scvi.data.setup_anndata(adata, batch_key="batch")
>>> vae = mypackage.MyModel(adata)
>>> vae.train()
>>> adata.obsm["X_mymodel"] = vae.get_latent_representation()

Attributes

device

history

Returns computed metrics during training.

is_trained

test_indices

train_indices

validation_indices

Methods

get_elbo([adata, indices, batch_size])

Return the ELBO for the data.

get_latent_representation([adata, indices, …])

Return the latent representation for each cell.

get_marginal_ll([adata, indices, …])

Return the marginal LL for the data.

get_reconstruction_error([adata, indices, …])

Return the reconstruction error for the data.

load(dir_path[, adata, use_gpu])

Instantiate a model from the saved output.

save(dir_path[, overwrite, save_anndata])

Save the state of the model.

to_device(device)

Move model to device.

train([max_epochs, use_gpu, train_size, …])

Train the model.