Neural network utils#
- class scconfluence.nn.DSBatchNorm(num_features, n_domain, eps=1e-05, momentum=0.1)#
Bases:
ModuleDomain-specific Batch Normalization, implementation from https://github.com/woozch/DSBN
- Parameters:
num_features – dimension of the features
n_domain – domain number
- forward(x, y)#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- reset_parameters()#
- reset_running_stats()#
- class scconfluence.nn.DecoderPeakVI(n_input: int, n_output: int, n_layers: int = 2, n_hidden: int = 128, n_batch: int = 1, use_batch_norm: str | None = None, deeply_inject_covariates: bool = True)#
Bases:
ModuleImported from https://github.com/YosefLab/scvi-tools/ and adapted. Decodes data from latent space of
n_inputdimensionsn_output``dimensions. Uses a fully-connected neural network of ``n_hiddenlayers.- forward(z: Tensor, batch_index: Tensor)#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class scconfluence.nn.DecoderSCVI(n_input: int, n_output: int, n_layers: int = 1, n_hidden: int = 128, n_batch: int = 1, use_batch_norm: str | None = None, deeply_inject_covariates: bool = True, use_poisson: bool = False)#
Bases:
ModuleImported from https://github.com/YosefLab/scvi-tools/ and adapted. Decodes data from latent space of
n_inputdimensions inton_outputdimensions. Uses a fully-connected neural network ofn_hiddenlayers.- forward(dispersion: str, z: Tensor, log_library: Tensor, batch_index: Tensor)#
The forward computation for a single sample.
- class scconfluence.nn.FCLayers(n_layers, n_input, n_hidden, n_output, n_batch=1, deeply_inject_covariates=True, use_batch_norm=None, activation_fn=<class 'torch.nn.modules.activation.ReLU'>, last_activation=False, positive_out=False, dropout_rate=0.0, bias=True)#
Bases:
ModuleImported from https://github.com/YosefLab/scvi-tools/ and adapted.
- forward(x, batch_index)#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- inject_into_layer(layer_num) bool#
Helper to determine if covariates should be injected.
- class scconfluence.nn.VariationalEncoder(n_input: int, n_output: int, n_layers: int = 1, n_hidden: int = 128, n_batch: int = 1, deeply_inject_covariates: bool = True, dropout_rate: float = 0.1, var_eps: float = 0.0001, var_activation=None, **kwargs)#
Bases:
ModuleImported from https://github.com/YosefLab/scvi-tools/ and adapted. Encodes data of
n_inputdimensions into a latent space ofn_outputdimensions. Uses a fully-connected neural network ofn_hiddenlayers.- forward(x: Tensor, batch_index: Tensor)#
The forward computation for a single sample.
- scconfluence.nn.get_batch_norm(flag, n_out, n_batch)#
Wrapper to obtain a batch normalization layer. :param flag: whether to use batch norm and which type :param n_out: the number of features :param n_batch: the number of batches in the data
- scconfluence.nn.one_hot(index: Tensor, n_cat: int) Tensor#
One hot a tensor of categories.
- scconfluence.nn.reparameterize_gaussian(mu, var)#