scvi.module.base.BaseModuleClass#
- class scvi.module.base.BaseModuleClass[source]#
Bases:
Module
Abstract class for scvi-tools modules.
Notes
See further usage examples in the following tutorials:
Attributes table#
Methods table#
|
Forward pass through the network. |
|
Run the generative model. |
|
Run the recognition model. |
|
Compute the loss for a minibatch of data. |
|
Callback function run in |
|
Generate samples from the learned model. |
Attributes#
- BaseModuleClass.training: bool#
Methods#
- BaseModuleClass.forward(tensors, get_inference_input_kwargs=None, get_generative_input_kwargs=None, inference_kwargs=None, generative_kwargs=None, loss_kwargs=None, compute_loss=True)[source]#
Forward pass through the network.
- Parameters:
tensors – tensors to pass through
get_inference_input_kwargs (
dict
|None
(default:None
)) – Keyword args for_get_inference_input()
get_generative_input_kwargs (
dict
|None
(default:None
)) – Keyword args for_get_generative_input()
inference_kwargs (
dict
|None
(default:None
)) – Keyword args forinference()
generative_kwargs (
dict
|None
(default:None
)) – Keyword args forgenerative()
loss_kwargs (
dict
|None
(default:None
)) – Keyword args forloss()
compute_loss (default:
True
) – Whether to compute loss on forward pass. This adds another return value.
- Return type:
tuple
[Tensor
,Tensor
] |tuple
[Tensor
,Tensor
,LossOutput
]
- abstractmethod BaseModuleClass.generative(*args, **kwargs)[source]#
Run the generative model.
This function should return the parameters associated with the likelihood of the data. This is typically written as \(p(x|z)\).
This function should return a dictionary with str keys and
Tensor
values.
- abstractmethod BaseModuleClass.inference(*args, **kwargs)[source]#
Run the recognition model.
In the case of variational inference, this function will perform steps related to computing variational distribution parameters. In a VAE, this will involve running data through encoder networks.
This function should return a dictionary with str keys and
Tensor
values.
- abstractmethod BaseModuleClass.loss(*args, **kwargs)[source]#
Compute the loss for a minibatch of data.
This function uses the outputs of the inference and generative functions to compute a loss. This many optionally include other penalty terms, which should be computed here.
This function should return an object of type
LossOutput
.- Return type: