smoother.models.reduction._spvae ================================ .. py:module:: smoother.models.reduction._spvae Classes ------- .. autoapisummary:: smoother.models.reduction._spvae.SPVAE smoother.models.reduction._spvae.SpatialVAE Module Contents --------------- .. py:class:: SPVAE(n_input: int, spatial_loss: Optional[smoother.SpatialLoss] = None, lambda_spatial_loss=0.1, sp_loss_as_kl: bool = False, n_hidden: int = 128, n_latent: int = 10, n_layers: int = 1, dropout_rate: float = 0.1, dispersion: Literal['gene', 'gene-batch', 'gene-label', 'gene-cell'] = 'gene', gene_likelihood: Literal['zinb', 'nb', 'poisson', 'normal'] = 'nb', latent_distribution: Literal['normal', 'ln'] = 'normal', **model_kwargs) Bases: :py:obj:`scvi.module.VAE` Add spatial loss to the latent representation in the VAE model. :param spatial_loss: Spatial loss to apply on the latent representation. If None, no spatial loss. :param lambda_spatial_loss: Weight of the spatial loss. :param sp_loss_as_kl: Whether to treat the spatial loss as a KL divergence term. If True, the spatial loss will replace the original KL divergence term in the loss function. If False, the spatial loss will be added to the original loss function. .. py:attribute:: spatial_loss :value: None .. py:attribute:: l_sp_loss :value: 0.1 .. py:attribute:: sp_loss_as_kl :value: False .. py:attribute:: diag_sp_inv_cov :value: None .. py:method:: loss(tensors, inference_outputs, generative_outputs, kl_weight: float = 1.0) Compute the loss. .. py:method:: from_vae(vae_module: scvi.module.VAE, spatial_loss: Optional[smoother.SpatialLoss] = None, lambda_spatial_loss=0.1, sp_loss_as_kl: bool = False) :classmethod: Alternate constructor to create a SPVAE model from a pretrained VAE model. .. py:class:: SpatialVAE(st_adata: anndata.AnnData, spatial_loss: Optional[smoother.SpatialLoss] = None, lambda_spatial_loss=0.1, sp_loss_as_kl: bool = False, n_hidden: int = 128, n_latent: int = 10, n_layers: int = 1, dropout_rate: float = 0.0, dispersion: Literal['gene', 'gene-batch', 'gene-label', 'gene-cell'] = 'gene', gene_likelihood: Literal['zinb', 'nb', 'poisson', 'normal'] = 'nb', latent_distribution: Literal['normal', 'ln'] = 'normal', **model_kwargs) Bases: :py:obj:`scvi.model.SCVI` Spatially-aware Variational Autoencoder model. .. py:attribute:: _data_splitter_cls .. py:attribute:: _module_cls .. py:attribute:: module .. py:attribute:: _model_summary_string .. py:attribute:: init_params_ .. py:attribute:: dr_logs .. py:method:: train(max_epochs: int = 400, lr: float = 0.01, accelerator: str = 'auto', devices: Union[int, List[int], str] = 'auto', plan_kwargs: Optional[dict] = None, **kwargs) Trains the model without mini-batch. .. py:method:: from_rna_model(st_adata: anndata.AnnData, sc_model: scvi.model.SCVI, spatial_loss: Optional[smoother.SpatialLoss] = None, lambda_spatial_loss=0.1, sp_loss_as_kl: bool = False, 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, **spvae_kwargs) :classmethod: Alternate constructor for exploiting a pre-trained model on RNA-seq 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. :param st_adata: registed anndata object :param sc_model: pretrained SCVI model