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,))
Tensor([...])
>>> d.log_prob(lucid.tensor(0.5))
Tensor(...)Used by 1
Constructors
1__init__
→None__init__(probs: Tensor | float | None = None, logits: Tensor | float | None = None, validate_args: bool | None = None)