Skip to content
data

NormalizingFlowOutput

extendsModelOutput
NormalizingFlowOutput(latent: Tensor, log_det_jacobian: Tensor, log_prob: Tensor, loss: Tensor | None = None)

Forward output of an exact-likelihood normalizing flow.

A flow's forward direction is the inference direction — it maps data to the latent space and reports how much volume the map contracted, so the exact log-density comes out of a single pass.

Attributes

latentTensor
Latent code h=f(x)h = f(x), shape (B, D) with D = C · H · W for image flows (the bijection is defined on the flattened sample).
log_det_jacobianTensor
Per-sample log⁡∣det⁡∂f/∂x∣\log\big|\det \partial f / \partial x\big|, shape (B,). Volume-preserving stages (additive coupling, permutations) contribute exactly zero.
log_probTensor
Per-sample exact log-likelihood, shape (B,): log⁡pX(x)=log⁡pH(f(x))+log⁡∣det⁡∂f/∂x∣.\log p_X(x) = \log p_H(f(x)) + \log\big|\det \partial f / \partial x\big|.
loss(Tensor or None, optional)
Scalar negative log-likelihood -log_prob.mean(), populated by the task wrapper (the bare trunk leaves it None).

Notes

Returned by NICEModel.forward and every other flow trunk / …ForImageGeneration head. Sampling runs the bijection backwards and returns GenerationOutput instead.

Examples

>>> import lucid
>>> from lucid.models import NormalizingFlowOutput
>>> out = NormalizingFlowOutput(
...     latent=lucid.zeros(4, 128),
...     log_det_jacobian=lucid.zeros(4),
...     log_prob=lucid.zeros(4),
... )
>>> out.latent.shape, out.log_prob.shape
((4, 128), (4,))

Used by 4