scvi.external.drvi.DecoderDRVI#
- class scvi.external.drvi.DecoderDRVI(n_input, n_output, n_split, split_method='split_map', n_split_output='auto', split_aggregation='logsumexp', n_cat_list=None, n_continuous_cov=0, n_layers=1, n_hidden=128, reuse_weights='everywhere', inject_covariates=True, use_batch_norm=False, use_layer_norm=True, model_cell_dispersion=False, model_zero_inflation=False, **kwargs)[source]#
Bases:
ModuleDRVI additive decoder: split the latent, decode each split, then aggregate.
Reuses scvi’s head structure (
px_scale_decoder,px_r_decoder,px_dropout_decoder) but, unlikeDecoderSCVI, returns the per-gene parameters in log space (aggregated scale logits, dispersion logits and zero-inflation logits). The library-size, softmax and exp transforms into count space are applied by the module (seegenerative()).The latent
zof dimensionn_latentis mapped inton_splitindependent groups, each decoded bySplitFCLayers, and the per-split parameters are aggregated over the split dimension (in log space; the count-space transforms are applied by the module).- Parameters:
n_input (
int) – Dimensionality of the latent space (n_latent); the dimension that is split.n_output (
int) – Number of genes.n_split (
int) – Number of latent splits. Must dividen_inputfor bothsplit_maskandsplit_map.split_method (
Literal['split_mask','split_map'] (default:'split_map')) –How the latent is mapped to splits.
"split_mask"— reshape inton_splitcontiguous chunks and place each chunk on its own split, zeroing the other chunks. Each split keeps the full latent widthn_input; e.g. withn_input=10andn_split=2the latent[1..10]becomes[[1,2,3,4,5,0,0,0,0,0], [0,0,0,0,0,6,7,8,9,10]]."split_map"— reshape inton_splitchunks of sizen_input // n_splitand apply a learned per-split linear map (StackedLinearLayer).
n_split_output (
int|Literal['auto'] (default:'auto')) – Per-split projection output width, i.e. the input dimension to each split’s decoder body."auto"(default) usesn_input(=n_latent). For"split_map"it is the output size of the learned per-split projection; for"split_mask"it must equaln_input.split_aggregation (
Literal['mean','logsumexp'] (default:'logsumexp')) –How per-split parameters are combined over the split dimension.
"mean"—sum / n_split."logsumexp"—logsumexp - log(n_split)(additive decoder in log space).
n_continuous_cov (
int(default:0)) – Number of continuous covariates injected into the decoder layers.reuse_weights (
Literal['everywhere','last','hidden','nowhere','hidden_except_first'] (default:'everywhere')) –Weight-sharing policy across splits, applied to the FC body (its
n_layershidden layers) and the parameter heads (“last”):"everywhere"(default) — hidden layers and heads all shared."hidden"— hidden layers shared, heads per-split."last"— hidden layers per-split, heads shared."hidden_except_first"— first hidden layer per-split, the rest and heads shared."nowhere"— hidden layers and heads all per-split.
Per-split weights use
StackedLinearLayer; shared weights are a singleLinearbroadcast over the split dimension.model_cell_dispersion (
bool(default:False)) – Whether to build a per-cell dispersion head (px_r_decoder). IfFalse(default), the decoder returnsNonefor the dispersion and the module uses a shared dispersion parameter instead (needed only fordispersion="gene-cell").model_zero_inflation (
bool(default:False)) – Whether to build a zero-inflation head (px_dropout_decoder). IfFalse(default), the decoder returnsNonefor the zero-inflation logits (needed only for thezinblikelihood).**kwargs – Keyword arguments for
SplitFCLayers.
Attributes table#
Methods table#
|
Decode |
Attributes#
- DecoderDRVI.training: bool#
Methods#
- DecoderDRVI.forward(z, *cat_list, cont=None)[source]#
Decode
zinto log-space per-gene parameters.Returns
(px_scale_logit, px_r_logit, px_dropout_logit, px_scale_logit_per_split): the aggregated per-gene scale logits (log space, before softmax), the per-cell dispersion logits, the zero-inflation logits, and the per-split scale logits before aggregation (only wheninspect_modeis set, elseNone). The dispersion and zero-inflation outputs areNoneunless the corresponding head was built (model_cell_dispersion/model_zero_inflation). The library-size, softmax and exp transforms are applied by the module (not here). Any number of leading dimensions (e.g. ann_samplesaxis) is supported and preserved: the split transform, the per-split FC layers and the aggregation all act on the last one or two dimensions.