BaseEncoder¶
- class pyraug.models.nn.BaseEncoder[source]¶
This is a base class for Encoders neural networks.
- forward(x)[source]¶
This function must be implemented in a child class. It takes the input data and returns (mu, log_var) in that order. If you decide to provide your own encoder network, you must make your model inherit from this class by setting and the define your forward function as such:
class My_Encoder(BaseEncoder): def __init__(self): BaseEncoder.__init__(self) # your code def forward(self, x): # your code return mu, log_var
- Parameters
x (torch.Tensor) – The input data that must be encoded
- Returns
The mean \(\mu_{\phi}\) and the log of the variance ():math:log Sigma) of the approximate distribution. As is common :Sigma is diagonal and so only the diagonal coefficients should be output
- Return type
(Tuple[torch.Tensor, torch.Tensor)
Warning
The output order in here important. Do not forget to set \(\mu\) as first argument and the log variance then.