AutoZIVAE¶
-
class
scvi.models.
AutoZIVAE
(n_input, alpha_prior=0.5, beta_prior=0.5, minimal_dropout=0.01, zero_inflation='gene', **args)[source]¶ Bases:
scvi.models.vae.VAE
AutoZI variational auto-encoder model.
Implementation of AutoZI model [Clivio19].
- n_input
Number of input genes
- alpha_prior
Float denoting the alpha parameter of the prior Beta distribution of the zero-inflation Bernoulli parameter. Should be between 0 and 1, not included. When set to ``None’’, will be set to 1 - beta_prior if beta_prior is not ``None’’, otherwise the prior Beta distribution will be learned on an Empirical Bayes fashion.
- beta_prior
Float denoting the beta parameter of the prior Beta distribution of the zero-inflation Bernoulli parameter. Should be between 0 and 1, not included. When set to ``None’’, will be set to 1 - alpha_prior if alpha_prior is not ``None’’, otherwise the prior Beta distribution will be learned on an Empirical Bayes fashion.
- minimal_dropout
Float denoting the lower bound of the cell-gene ZI rate in the ZINB component. Must be non-negative. Can be set to 0 but not recommended as this may make the mixture problem ill-defined.
zero_inflation: One of the following
'gene'
- zero-inflation Bernoulli parameter of AutoZI is constant per gene across cells'gene-batch'
- zero-inflation Bernoulli parameter can differ between different batches'gene-label'
- zero-inflation Bernoulli parameter can differ between different labels'gene-cell'
- zero-inflation Bernoulli parameter can differ for every gene in every cell
See VAE docstring (scvi/models/vae.py) for more parameters.
reconstruction_loss
should not be specified.Examples
>>> gene_dataset = CortexDataset() >>> autozivae = AutoZIVAE(gene_dataset.nb_genes, alpha_prior=0.5, beta_prior=0.5, minimal_dropout=0.01)
Methods Summary
cuda
([device])Moves all model parameters and also fixed prior alpha and beta values, when relevant, to the GPU.
forward
(x, local_l_mean, local_l_var[, …])Returns the reconstruction loss and the Kullback divergences
get_alphas_betas
([as_numpy])get_reconstruction_loss
(x, px_rate, px_r, …)inference
(x[, batch_index, y, n_samples, …])Helper function used in forward pass
rescale_dropout
(px_dropout[, eps_log])reshape_bernoulli
(bernoulli_params[, …])sample_bernoulli_params
([batch_index, y, …])sample_from_beta_distribution
(alpha, beta[, …])Methods Documentation
-
cuda
(device=None)[source]¶ Moves all model parameters and also fixed prior alpha and beta values, when relevant, to the GPU.
-
forward
(x, local_l_mean, local_l_var, batch_index=None, y=None)[source]¶ Returns the reconstruction loss and the Kullback divergences
- Parameters
x (
Tensor
Tensor
) – tensor of values with shape (batch_size, n_input)local_l_mean (
Tensor
Tensor
) – tensor of means of the prior distribution of latent variable l with shape (batch_size, 1)local_l_var (
Tensor
Tensor
) – tensor of variancess of the prior distribution of latent variable l with shape (batch_size, 1)batch_index (
Tensor
,None
Optional
[Tensor
]) – array that indicates which batch the cells belong to with shapebatch_size
y (
Tensor
,None
Optional
[Tensor
]) – tensor of cell-types labels with shape (batch_size, n_labels)
- Return type
- Returns
2-tuple of
torch.FloatTensor
the reconstruction loss and the Kullback divergences
-
get_reconstruction_loss
(x, px_rate, px_r, px_dropout, bernoulli_params, eps_log=1e-08, **kwargs)[source]¶