core.decoders#
This module contains the classes defining the decoder (core.decoder.Decoder).
- class bulkdgd.core.decoders.Decoder(n_units_input_layer: int, n_units_hidden_layers: int, activations: object, output_module_name: str, output_module_options: dict[str, object], dropout: float = 0.0)#
Class implementing the decoder.
- __init__(n_units_input_layer: int, n_units_hidden_layers: int, activations: object, output_module_name: str, output_module_options: dict[str, object], dropout: float = 0.0) None#
Initialize an instance of the neural network representing the decoder.
- Parameters:
- n_units_input_layer
int The number of neurons in the input layer.
- n_units_hidden_layers
list The number of units in each of the hidden layers. As many hidden layers as the number of items in the list will be created.
- activations
list A list containing the names of the activation functions to use in each hidden layer. Available activation functions are:
"relu": the ReLU function."elu": the ELU function.
- output_module_name
str, {"nb_feature_dispersion","nb_full_dispersion","poisson"} The name of the output module that will be set. Available output modules are:
"nb_feature_dispersion"for negative binomial distributions with means learned per gene per sample and r-values learned per gene."nb_full_dispersion"for negative binomial distributions with both means and r-values learned per gene per sample."poisson"for Poisson distributions with means learned per gene per sample.
- output_module_options
dict A dictionary of options for setting up the output module.
For the
"nb_feature_dispersion"output module, the following options must be provided:"activation": the name of the activation function to be used in the output module."r_init": the initial r-value for the negative binomial distributions modeling the genes’ counts.
For the
"nb_full_dispersion"output module, the following options must be provided:"activation": the name of the activation function to be used in the output module.
For the
"poisson"output module, the following options must be provided:"activation": the name of the activation function to be used in the output module.
- dropout
float The dropout rate to be used in the decoder. By default, it is 0.0 (no dropout).
- n_units_input_layer
- forward(z: Tensor) Tensor#
Forward pass through the neural network.
- Parameters:
- z
torch.Tensor A tensor holding the representations to pass through the decoder.
- z
- Returns:
- y
torch.Tensor A tensor holding the outputs of the decoder for the given representations.
- y