torch_geometric.nn.models.VGAE
- class VGAE(encoder: Module, decoder: Optional[Module] = None)[source]
Bases:
GAE
The Variational Graph Auto-Encoder model from the “Variational Graph Auto-Encoders” paper.
- Parameters:
encoder (torch.nn.Module) – The encoder module to compute \(\mu\) and \(\log\sigma^2\).
decoder (torch.nn.Module, optional) – The decoder module. If set to
None
, will default to thetorch_geometric.nn.models.InnerProductDecoder
. (default:None
)
- reset_parameters()
Resets all learnable parameters of the module.
- kl_loss(mu: Optional[Tensor] = None, logstd: Optional[Tensor] = None) Tensor [source]
Computes the KL loss, either for the passed arguments
mu
andlogstd
, or based on latent variables from last encoding.- Parameters:
mu (torch.Tensor, optional) – The latent space for \(\mu\). If set to
None
, uses the last computation of \(\mu\). (default:None
)logstd (torch.Tensor, optional) – The latent space for \(\log\sigma\). If set to
None
, uses the last computation of \(\log\sigma^2\). (default:None
)
- Return type: