Predictive¶
Predictive inference and posterior sampling.
predictive
¶
Posterior predictive sampling.
Given a trained posterior representation — either a variational
guide or an MCMC chain — Predictive repeatedly samples
latents from the posterior and traces the model forward to produce
posterior predictive draws of every site.
Predictive
¶
Predictive(model: MonadicProgram, posterior: Guide | MCMCResult, num_samples: int | None = None)
Posterior predictive sampler.
Accepts either a trained Guide (variational
posterior) or an MCMCResult (Monte Carlo posterior).
Variational case: draws num_samples fresh guide samples.
MCMC case: iterates over the recorded posterior draws (one
forward trace per draw, up to num_samples if specified).
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model.
TYPE:
|
posterior
|
Trained posterior representation.
TYPE:
|
num_samples
|
Number of predictive draws. Defaults to
TYPE:
|
Source code in src/quivers/inference/predictive.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
__call__
¶
__call__(x: Tensor, observations: dict[str, Tensor] | None = None) -> dict[str, Tensor]
Draw posterior predictive samples.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
observations
|
Additional observed data to condition on.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
One key per site, value of shape
|
Source code in src/quivers/inference/predictive.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |