scvi.core.modules.AutoZIVAE

class scvi.core.modules.AutoZIVAE(n_input, alpha_prior=0.5, beta_prior=0.5, minimal_dropout=0.01, zero_inflation='gene', **args)[source]

Implementation of the AutoZI model [Clivio19].

Parameters
n_input : intint

Number of input genes

alpha_prior : float, NoneOptional[float] (default: 0.5)

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, NoneOptional[float] (default: 0.5)

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 : floatfloat (default: 0.01)

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)

Attributes

T_destination

dump_patches

Methods

add_module(name, module)

Adds a child module to the current module.

apply(fn)

Applies fn recursively to every submodule (as returned by .children()) as well as self.

bfloat16()

Casts all floating point parameters and buffers to bfloat16 datatype.

buffers([recurse])

Returns an iterator over module buffers.

children()

Returns an iterator over immediate children modules.

compute_global_kl_divergence()

rtype

TensorTensor

cpu()

Moves all model parameters and buffers to the CPU.

cuda([device])

Moves relevant parameters to the GPU.

double()

Casts all floating point parameters and buffers to double datatype.

eval()

Sets the module in evaluation mode.

extra_repr()

Set the extra representation of the module

float()

Casts all floating point parameters and buffers to float datatype.

forward(x, local_l_mean, local_l_var[, …])

Returns the reconstruction loss and the Kullback divergences.

get_alphas_betas([as_numpy])

rtype

{str: Tensor, ndarray}Dict[str, Union[Tensor, ndarray]]

get_latents(x[, y])

Returns the result of sample_from_posterior_z inside a list.

get_reconstruction_loss(x, px_rate, px_r, …)

rtype

TensorTensor

get_sample_rate(x[, batch_index, y, …])

Returns the tensor of means of the negative binomial distribution.

get_sample_scale(x[, batch_index, y, …])

Returns the tensor of predicted frequencies of expression.

half()

Casts all floating point parameters and buffers to half datatype.

inference(x[, batch_index, y, n_samples, …])

Helper function used in forward pass.

load_state_dict(state_dict[, strict])

Copies parameters and buffers from state_dict into this module and its descendants.

modules()

Returns an iterator over all modules in the network.

named_buffers([prefix, recurse])

Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.

named_children()

Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself.

named_modules([memo, prefix])

Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself.

named_parameters([prefix, recurse])

Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.

parameters([recurse])

Returns an iterator over module parameters.

register_backward_hook(hook)

Registers a backward hook on the module.

register_buffer(name, tensor[, persistent])

Adds a buffer to the module.

register_forward_hook(hook)

Registers a forward hook on the module.

register_forward_pre_hook(hook)

Registers a forward pre-hook on the module.

register_parameter(name, param)

Adds a parameter to the module.

requires_grad_([requires_grad])

Change if autograd should record operations on parameters in this module.

rescale_dropout(px_dropout[, eps_log])

rtype

TensorTensor

reshape_bernoulli(bernoulli_params[, …])

rtype

TensorTensor

sample_bernoulli_params([batch_index, y, …])

rtype

TensorTensor

sample_from_beta_distribution(alpha, beta[, …])

rtype

TensorTensor

sample_from_posterior_l(x[, give_mean])

Samples the tensor of library sizes from the posterior.

sample_from_posterior_z(x[, y, give_mean, …])

Samples the tensor of latent values from the posterior.

share_memory()

rtype

~T~T

state_dict([destination, prefix, keep_vars])

Returns a dictionary containing a whole state of the module.

to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

train([mode])

Sets the module in training mode.

type(dst_type)

Casts all parameters and buffers to dst_type.

zero_grad()

Sets gradients of all model parameters to zero.