scvi.nn.FCLayers#
- class scvi.nn.FCLayers(n_in, n_out, n_cat_list=None, n_layers=1, n_hidden=128, dropout_rate=0.1, use_batch_norm=True, use_layer_norm=False, use_activation=True, bias=True, inject_covariates=True, activation_fn=<class 'torch.nn.modules.activation.ReLU'>)[source]#
Bases:
Module
A helper class to build fully-connected layers for a neural network.
- Parameters:
n_in (int) – The dimensionality of the input
n_out (int) – The dimensionality of the output
n_cat_list (Iterable[int]) – A list containing, for each category of interest, the number of categories. Each category will be included using a one-hot encoding.
n_layers (int) – The number of fully-connected hidden layers
n_hidden (int) – The number of nodes per hidden layer
dropout_rate (float) – Dropout rate to apply to each of the hidden layers
use_batch_norm (bool) – Whether to have
BatchNorm
layers or notuse_layer_norm (bool) – Whether to have
LayerNorm
layers or notuse_activation (bool) – Whether to have layer activation or not
bias (bool) – Whether to learn bias in linear layers or not
inject_covariates (bool) – Whether to inject covariates in each layer, or just the first (default).
activation_fn (Module) – Which activation function to use
Attributes table#
Methods table#
|
Forward computation on |
|
Helper to determine if covariates should be injected. |
|
Set online update hooks. |
Attributes#
training
Methods#
forward
- FCLayers.forward(x, *cat_list)[source]#
Forward computation on
x
.- Parameters:
- Returns:
torch.Tensor
tensor of shape(n_out,)
inject_into_layer
- FCLayers.inject_into_layer(layer_num)[source]#
Helper to determine if covariates should be injected.
- Return type:
set_online_update_hooks