ContinuousBernoulli
DistributionContinuousBernoulli(probs: Tensor | float | None = None, logits: Tensor | float | None = None, validate_args: bool | None = None)Continuous Bernoulli distribution on .
A continuous relaxation of the lucid.distributions.Bernoulli
distribution introduced by Loaiza-Ganem & Cunningham (2019) to fix the
well-known bias incurred by VAE decoders that use a Bernoulli
likelihood on real-valued image pixels in . Unlike the
naive "Bernoulli on [0,1]" likelihood, the Continuous Bernoulli has a
proper normalising constant and yields unbiased ELBO gradients.
Parameters
Notes
Probability density on :
where the normalising constant is
Mean (closed form):
Important properties:
- Support: (continuous, not just ).
- Reduces to at .
- At or the density concentrates near 0 or 1 respectively.
- Reparameterisable via inverse CDF.
The Continuous Bernoulli is the correct likelihood for decoders that output a value in (e.g. MNIST pixel intensities) when the model is to remain a valid probabilistic model. Using a plain Bernoulli on continuous data produces an improper density and a systematically biased ELBO.
Examples
>>> import lucid
>>> from lucid.distributions import ContinuousBernoulli
>>> d = ContinuousBernoulli(probs=0.7)
>>> d.rsample((4,)).shape
(4,)
>>> d.log_prob(lucid.tensor(0.5))
tensor(-0.02974)Used by 1
Constructors
1__init__
→None__init__(probs: Tensor | float | None = None, logits: Tensor | float | None = None, validate_args: bool | None = None)Properties
2Instance methods
4x · l − softplus(l) + log C(p).
Log-odds of — as given, or derived on access.
Derived from probs clamped one epsilon inside , as
the reference framework derives it.
Parameter — as given, or sigmoid(logits).
Reparameterised sample via the closed-form icdf.