scvi.external.mrvi.MRVAE#
- class scvi.external.mrvi.MRVAE(n_input, n_sample, n_batch, n_labels, n_latent=30, n_latent_u=10, encoder_n_hidden=128, encoder_n_layers=2, z_u_prior=True, z_u_prior_scale=0.0, u_prior_scale=0.0, u_prior_mixture=True, u_prior_mixture_k=20, learn_z_u_prior_scale=False, scale_observations=False, px_kwargs=None, qz_kwargs=None, qu_kwargs=None, n_obs_per_sample=None)[source]#
Bases:
BaseModuleClassMulti-resolution Variational Inference (MrVI) module.
- Parameters:
- n_input
int Number of input features.
- n_sample
int Number of samples.
- n_batch
int Number of batches.
- n_labels
int Number of labels.
- n_latent
int(default:30) Number of latent variables for
z.- n_latent_u
int(default:10) Number of latent variables for
u.- encoder_n_hidden
int(default:128) Number of hidden units in the encoder.
- encoder_n_layers
int(default:2) Number of layers in the encoder.
- z_u_prior
bool(default:True) Whether to place a Gaussian prior on
zgivenu.- z_u_prior_scale
float(default:0.0) Natural log of the scale parameter of the Gaussian prior placed on
zgivenu. Only applies oflearn_z_u_prior_scaleisFalse.- u_prior_scale
float(default:0.0) Natural log of the scale parameter of the Gaussian prior placed on
u. Ifu_prior_mixtureisTrue, this scale applies to each mixture component distribution.- u_prior_mixture
bool(default:True) Whether to use a mixture of Gaussians prior for
u.- u_prior_mixture_k
int(default:20) Number of mixture components to use for the mixture of Gaussians prior on
u.- learn_z_u_prior_scale
bool(default:False) Whether to learn the scale parameter of the prior distribution of
zgivenu.- scale_observations
bool(default:False) Whether to scale the loss associated with each observation by the total number of observations linked to the associated sample.
- px_kwargs
dict|None(default:None) Keyword arguments for the generative model.
- qz_kwargs
dict|None(default:None) Keyword arguments for the inference model from
utoz.- qu_kwargs
dict|None(default:None) Keyword arguments for the inference model from
xtou.- training
Whether the model is in training mode.
- n_obs_per_sample
Tensor|None(default:None) Number of observations per sample.
- n_input
Attributes table#
Methods table#
|
Compute normalized gene expression from observations using predefined eps |
|
Generative model. |
|
Run the recognition model. |
|
Compute the loss function value. |
Attributes#
Methods#
- MRVAE.compute_h_from_x_eps(x, sample_index, batch_index, extra_eps, cf_sample=None, mc_samples=10)[source]#
Compute normalized gene expression from observations using predefined eps
- MRVAE.generative(z, library, batch_index, label_index, transform_batch=None)[source]#
Generative model.
- Return type:
dict[str,Tensor|Distribution]
- MRVAE.inference(x, sample_index, mc_samples=None, cf_sample=None, use_mean=False)[source]#
Run the recognition model.
In the case of variational inference, this function will perform steps related to computing variational distribution parameters. In a VAE, this will involve running data through encoder networks.
This function should return a dictionary with str keys and
Tensorvalues.