iVAE.environment.Env
- class iVAE.environment.Env(adata, layer, percent, irecon, beta, dip, tc, info, hidden_dim, latent_dim, i_dim, lr, device, *args, **kwargs)[source]
Training environment for the iVAE model.
This class manages the training workflow including data preprocessing, batch sampling, model updates, and performance evaluation. It inherits from both iVAE (the model) and envMixin (evaluation utilities).
- Parameters:
adata (anndata.AnnData) – Annotated data matrix containing single-cell gene expression data.
layer (str) – Name of the layer in adata.layers to use for training.
percent (float) – Proportion of data to use in each training batch (0 < percent <= 1).
irecon (float) – Weight for interpretative reconstruction loss.
beta (float) – Weight for KL divergence term.
dip (float) – Weight for DIP loss.
tc (float) – Weight for total correlation loss.
info (float) – Weight for InfoVAE MMD loss.
hidden_dim (int) – Dimension of hidden layers in the neural network.
latent_dim (int) – Dimension of the main latent space.
i_dim (int) – Dimension of the interpretative latent space.
lr (float) – Learning rate for optimization.
device (torch.device) – Device for computation (CPU or CUDA).
- X
Log-normalized gene expression matrix of shape (n_cells, n_genes).
- Type:
numpy.ndarray
- n_obs
Number of cells (observations).
- Type:
int
- n_var
Number of genes (variables).
- Type:
int
- batch_size
Number of samples per training batch.
- Type:
int
- labels
Reference cluster labels for evaluation (from K-means on input data).
- Type:
numpy.ndarray
- score
Training history of evaluation scores.
- Type:
list
- __init__(adata, layer, percent, irecon, beta, dip, tc, info, hidden_dim, latent_dim, i_dim, lr, device, *args, **kwargs)[source]
Methods
__init__(adata, layer, percent, irecon, ...)load_data()Load a random batch of data for training.
step(data)Perform one training step: update model and evaluate performance.
take_latent(state)Extract latent representations from input data.
update(states)Perform one training step with the given batch of data.