Conditioning¶
Conditioning on observations and evidence in probabilistic programs.
conditioning
¶
Conditioning: pair a program with observed data.
The condition function wraps a MonadicProgram with a dict of
observations, producing a Conditioned object that threads those
observations through tracing and log-joint evaluation. This is the
primary interface for specifying observed data in inference.
Conditioned
¶
Conditioned(model: MonadicProgram, data: dict[str, Tensor])
A monadic program paired with observed data.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
The generative model.
TYPE:
|
data
|
Observed variable names mapped to their observed values.
TYPE:
|
Source code in src/quivers/inference/conditioning.py
29 30 31 32 33 34 35 | |
trace
¶
trace(x: Tensor) -> Trace
Execute the model with observations clamped.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape (batch, ...).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Trace
|
Execution trace with observed sites clamped. |
Source code in src/quivers/inference/conditioning.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
condition
¶
condition(model: MonadicProgram, data: dict[str, Tensor]) -> Conditioned
Condition a model on observed data.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
The generative model.
TYPE:
|
data
|
Observed variable names mapped to their observed values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Conditioned
|
Wrapped model with observations. |
Source code in src/quivers/inference/conditioning.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |