nichecompass.nn.Encoder
- class nichecompass.nn.Encoder(n_input, n_cat_covariates_embed_input, n_hidden, n_latent, n_addon_latent=100, n_fc_layers=1, conv_layer='gatv2conv', n_layers=1, cat_covariates_embed_mode='input', n_attention_heads=4, dropout_rate=0.0, activation=torch.nn.ReLU, use_bn=True)
Encoder class.
Takes the input space features x and the edge indices as input, first computes fully connected layers and then uses message passing layers to output mu and logstd of the latent space normal distribution.
- Parameters:
n_input (
int) – Number of input nodes (omics features) to the encoder.n_cat_covariates_embed_input (
int) – Number of categorical covariates embedding input nodes to the encoder.n_hidden (
int) – Number of hidden nodes outputted after the fully connected layers and intermediate message passing layers.n_latent (
int) – Number of output nodes (prior gps) from the encoder, making up the first part of the latent space features z.n_addon_latent (
int(default:100)) – Number of add-on nodes in the latent space (new gps), making up the second part of the latent space features z.n_fc_layers (
int(default:1)) – Number of fully connected layers before the message passing layers.conv_layer (
Literal['gcnconv','gatv2conv'] (default:'gatv2conv')) – Message passing layer used.n_layers (
int(default:1)) – Number of message passing layers.cat_covariates_embed_mode (
Literal['input','hidden'] (default:'input')) – Indicates where to inject the categorical covariates embedding if injected.n_attention_heads (
int(default:4)) – Only relevant if ´conv_layer == gatv2conv´. Number of attention heads used.dropout_rate (
float(default:0.0)) – Probability of nodes to be dropped in the hidden layer during training.activation (
Module(default:torch.nn.ReLU)) – Activation function used after the fully connected layers and intermediate message passing layers.use_bn (
bool(default:True)) – If ´True´, use a batch normalization layer at the end to normalize ´mu´.
Methods table
|
Forward pass of the encoder. |
Methods
- Encoder.forward(x, edge_index, cat_covariates_embed=None)
Forward pass of the encoder.
- Parameters:
x (
Tensor) – Tensor containing the omics features.edge_index (
Tensor) – Tensor containing the edge indices for message passing.cat_covariates_embed (
Optional[Tensor] (default:None)) – Tensor containing the categorical covariates embedding (all categorical covariates embeddings concatenated into one embedding).
- Return type:
Tuple[Tensor,Tensor]- Returns:
- mu:
Tensor containing the expected values of the latent space normal distribution.
- logstd:
Tensor containing the log standard deviations of the latent space normal distribution.