data
VAEOutput
extends
ModelOutputVAEOutput(sample: Tensor, latent: Tensor, mu: Tensor, logvar: Tensor, loss: Tensor | None = None, recon_loss: Tensor | None = None, kl_loss: Tensor | None = None)End-to-end VAE forward output.
Attributes
sampleTensorReconstructed image shaped
(B, C, H, W).latentTensorSampled latent , shape
(B, latent_dim).muTensorEncoder mean .
logvarTensorEncoder log-variance .
loss(Tensor or None, optional)Total ELBO loss (
recon_loss + β · kl_loss) when targets were
supplied to forward.recon_loss(Tensor or None, optional)Reconstruction term alone (typically BCE or MSE).
kl_loss(Tensor or None, optional)KL divergence term alone.
Notes
Returned by VAEModel.forward. VAEForImageGeneration
wraps the decoder for unconditional sampling and returns
GenerationOutput from its generate method.
Examples
>>> import lucid
>>> from lucid.models import VAEOutput
>>> out = VAEOutput(
... sample=lucid.zeros(1, 3, 32, 32),
... latent=lucid.zeros(1, 128),
... mu=lucid.zeros(1, 128),
... logvar=lucid.zeros(1, 128),
... )
>>> out.sample.shape, out.latent.shape
((1, 3, 32, 32), (1, 128))
The reconstruction and KL terms are kept apart from the total so a
caller can watch them move against each other during training.
>>> out.recon_loss is None, out.kl_loss is None
(True, True)