smoother.models.reduction._spmultivi
Classes
Add spatial loss to the latent representation in the MULTIVAE model. |
|
Spatially-aware Multimodal Variational Autoencoder model. |
Functions
|
Get the reconstruction loss for protein data. |
Module Contents
- smoother.models.reduction._spmultivi.get_reconstruction_loss_protein(y, py_, pro_batch_mask_minibatch=None)
Get the reconstruction loss for protein data.
- class smoother.models.reduction._spmultivi.SPMULTIVAE(spatial_loss: smoother.SpatialLoss | None = None, lambda_spatial_loss: float = 1, sp_loss_as_kl: bool = True, **model_kwargs)
Bases:
scvi.module.MULTIVAEAdd spatial loss to the latent representation in the MULTIVAE model.
- Parameters:
spatial_loss – Spatial loss to apply on the latent representation. If None, no spatial loss.
lambda_spatial_loss – Weight of the spatial loss.
sp_loss_as_kl – Whether to apply the spatial loss as a KL term (i.e. replacing the original Normal(0, 1) prior) or as a separate global term.
- spatial_loss = None
- l_sp_loss = 1
- sp_loss_as_kl = True
- diag_sp_inv_cov = None
- loss(tensors, inference_outputs, generative_outputs, kl_weight: float = 1.0) scvi.module.base.LossOutput
Computes the loss function for the model.
- classmethod from_vae(vae_module: scvi.module.MULTIVAE, spatial_loss: smoother.SpatialLoss | None = None, lambda_spatial_loss: float = 1, sp_loss_as_kl: bool = True)
- class smoother.models.reduction._spmultivi.SpatialMULTIVI(st_adata: anndata.AnnData, spatial_loss: smoother.SpatialLoss | None = None, lambda_spatial_loss: float = 1, sp_loss_as_kl: bool = True, **model_kwargs)
Bases:
scvi.model.MULTIVISpatially-aware Multimodal Variational Autoencoder model.
- _data_splitter_cls
- _module_cls
- module
- _model_summary_string
- init_params_
- dr_logs
- train(max_epochs: int = 500, lr: float = 0.0001, accelerator: str = 'auto', devices='auto', weight_decay: float = 0.001, eps: float = 1e-08, n_steps_kl_warmup=None, n_epochs_kl_warmup=50, adversarial_mixing=False, datasplitter_kwargs=None, plan_kwargs=None, **kwargs)
Train the model without mini-batch.
- classmethod from_sc_model(st_adata: mudata.MuData, sc_model: scvi.model.MULTIVI, spatial_loss: smoother.SpatialLoss | None = None, lambda_spatial_loss: float = 1, sp_loss_as_kl: bool = True, unfrozen: bool = False, freeze_dropout: bool = False, freeze_expression: bool = True, freeze_decoder_first_layer: bool = True, freeze_batchnorm_encoder: bool = True, freeze_batchnorm_decoder: bool = False, freeze_classifier: bool = True, **spmultivae_kwargs)
Alternate constructor for exploiting a pre-trained model on non-spatial data.
Note that because of the dropout layer, even though the new instance is initialized with the same parameters as the pre-trained model, new_instance.get_latent_representation() may not return the same latent representation as the pre-trained model.
- Parameters:
st_adata – registed anndata object
sc_model – pretrained MULTIVI model