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_layerint

The number of neurons in the input layer.

n_units_hidden_layerslist

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.

activationslist

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_namestr, {"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_optionsdict

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.

dropoutfloat

The dropout rate to be used in the decoder. By default, it is 0.0 (no dropout).

forward(z: Tensor) Tensor#

Forward pass through the neural network.

Parameters:
ztorch.Tensor

A tensor holding the representations to pass through the decoder.

Returns:
ytorch.Tensor

A tensor holding the outputs of the decoder for the given representations.