ELBO¶
Evidence lower bound computation for variational inference.
elbo
¶
Evidence lower bound (ELBO) computation.
The ELBO is the central objective for variational inference:
ELBO = E_q[log p(x, z) - log q(z)]
Maximizing the ELBO is equivalent to minimizing KL(q || p). This module computes the negative ELBO (a loss to minimize) using Monte Carlo estimation with multiple particles.
ELBO
¶
ELBO(num_particles: int = 1)
Bases: Module
Compute the negative ELBO (loss to minimize).
| PARAMETER | DESCRIPTION |
|---|---|
num_particles
|
Number of Monte Carlo samples for estimating the expectation.
TYPE:
|
Source code in src/quivers/inference/elbo.py
30 31 32 | |
forward
¶
forward(model: MonadicProgram, guide: Guide, x: Tensor, observations: dict[str, Tensor]) -> Tensor
Compute negative ELBO.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
The generative model.
TYPE:
|
guide
|
The variational guide.
TYPE:
|
x
|
Program input. Shape (batch, ...).
TYPE:
|
observations
|
Observed variable values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Scalar negative ELBO (averaged over batch and particles). |
Source code in src/quivers/inference/elbo.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |