nichecompass.nn.AddOnMaskedLayer

class nichecompass.nn.AddOnMaskedLayer(n_input, n_output, mask, addon_mask, masked_features_idx, bias=False, n_addon_input=0, n_cat_covariates_embed_input=0, activation=torch.nn.Softmax)

Add-on masked layer class.

Parts of the implementation are adapted from https://github.com/theislab/scarches/blob/7980a187294204b5fb5d61364bb76c0b809eb945/scarches/models/expimap/modules.py#L28; 01.10.2022.

Parameters:
  • n_input (int) – Number of mask input nodes to the add-on masked layer.

  • n_output (int) – Number of output nodes from the add-on masked layer.

  • mask (Tensor) – Mask that is used to mask the node connections for mask inputs from the input layer to the output layer.

  • addon_mask (Tensor) – Mask that is used to mask the node connections for add-on inputs from the input layer to the output layer.

  • masked_features_idx (List) – Index of input features that are included in the mask.

  • bias (bool (default: False)) – If ´True´, use a bias for the mask input nodes.

  • n_addon_input (int (default: 0)) – Number of add-on input nodes to the add-on masked layer.

  • n_cat_covariates_embed_input (int (default: 0)) – Number of categorical covariates embedding input nodes to the addon masked layer.

  • activation (Module (default: torch.nn.Softmax)) – Activation function used at the end of the ad-on masked layer.

Methods table

forward(input[, dynamic_mask])

Forward pass of the add-on masked layer.

Methods

AddOnMaskedLayer.forward(input, dynamic_mask=None)

Forward pass of the add-on masked layer.

Parameters:
  • input (Tensor) – Input features to the add-on masked layer. Includes add-on input nodes and categorical covariates embedding input nodes if specified.

  • dynamic_mask (Optional[Tensor] (default: None)) – Additional optional dynamic mask for the masked layer.

Return type:

Tensor

Returns:

output: Output of the add-on masked layer.