FCLayers

class scvi.models.modules.FCLayers(n_in, n_out, n_cat_list=None, n_layers=1, n_hidden=128, dropout_rate=0.1, use_batch_norm=True, use_relu=True, bias=True)[source]

Bases: torch.nn.modules.module.Module

A helper class to build fully-connected layers for a neural network.

Parameters
  • n_in (intint) – The dimensionality of the input

  • n_out (intint) – The dimensionality of the output

  • n_cat_list (Iterable[int], NoneOptional[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 (intint) – The number of fully-connected hidden layers

  • n_hidden (intint) – The number of nodes per hidden layer

  • dropout_rate (floatfloat) – Dropout rate to apply to each of the hidden layers

  • use_batch_norm (boolbool) – Whether to have BatchNorm layers or not

  • use_relu (boolbool) – Whether to have ReLU layers or not

  • bias (boolbool) – Whether to learn bias in linear layers or not

Methods Summary

forward(x, *cat_list[, instance_id])

Forward computation on x.

Methods Documentation

forward(x, *cat_list, instance_id=0)[source]

Forward computation on x.

Parameters
  • x (torch.Tensor) – tensor of values with shape (n_in,)

  • cat_list (intint) – list of category membership(s) for this sample

  • instance_id (intint) – Use a specific conditional instance normalization (batchnorm)

  • x

Returns

py:class:torch.Tensor tensor of shape (n_out,)