Variational Guides¶
A variational guide is a family of distributions
over the unobserved sites whose parameters
optimization adjusts to
approximate the posterior (Pyro Developers, n.d.-g; Blei et al., 2017; Hoffman et al., 2013). The guides live in
submodules of quivers.inference.guides and share the Guide abstract base class and the
LatentRegistry. They are AutoNormalGuide, AutoDeltaGuide, AutoMultivariateNormalGuide,
AutoLowRankMultivariateNormalGuide, AutoLaplaceApproximation, AutoNormalizingFlow,
AutoIAFGuide, AutoNeuralSplineGuide, AutoMixtureGuide, AutoGuideList, AutoStructured, and
AmortizedGuide, which runs declared encoders on
the data. Independent Normal guides
represent marginal locations and scales, and covariance and flow guides also represent
dependence.
quivers.inference re-exports every guide, and quivers.inference.guides
adds the short names that Pyro uses (AutoNormal, AutoMultivariateNormal,
AutoLowRankMVN, AutoDelta, AutoLaplace, AutoIAFNormal), each bound
to the guide class it names, and the type aliases that configure
AutoStructured.
The Laplace approximation uses a quadratic expansion around a mode (MacKay, 2003; Tierney and Kadane, 1986). The autoregressive flow implementations use masked networks (Germain et al., 2015). The invertible linear transform follows the construction used in Glow (Kingma and Dhariwal, 2018).
guides
¶
Variational guide families.
Public surface (re-exported by the parent quivers.inference
package): one ABC (Guide) plus a zoo of concrete
Auto*Guide subclasses spanning the standard variational-family
ladder from mean-field Normal to normalizing-flow stacks and
hierarchical / mixture / structured guides.
Every concrete guide is built against a single
quivers.inference.registry.LatentRegistry and obeys the
shape contract documented on Guide.
Short-name aliases matching the Pyro AutoGuide naming
(AutoNormal, AutoMultivariateNormal, AutoLowRankMVN,
AutoDelta, AutoLaplace, AutoIAFNormal) are re-exported for
users switching over from Pyro. The longer *Guide names remain
the canonical quivers names.
AutoNormal
module-attribute
¶
AutoNormal = AutoNormalGuide
Pyro-style short name for AutoNormalGuide.
AutoMultivariateNormal
module-attribute
¶
AutoMultivariateNormal = AutoMultivariateNormalGuide
Pyro-style short name for AutoMultivariateNormalGuide.
AutoLowRankMVN
module-attribute
¶
AutoLowRankMVN = AutoLowRankMultivariateNormalGuide
Pyro-style short name for AutoLowRankMultivariateNormalGuide.
AutoLaplace
module-attribute
¶
AutoLaplace = AutoLaplaceApproximation
Pyro-style short name for AutoLaplaceApproximation.
AutoIAFNormal
module-attribute
¶
AutoIAFNormal = AutoIAFGuide
Pyro-style short name for AutoIAFGuide.
ConditionalSpec
¶
The per-site marginal families of an AutoStructured guide: one
family name ("delta", "normal", or "mvn") for every site,
or a mapping from site name to family name.
DependencyKind
¶
One dependency edge of an AutoStructured guide: the string
"linear" for a learned linear shift, or a callable mapping the
parent's unconstrained flat draw to a shift on the child's
unconstrained flat location.
DependencySpec
¶
DependencySpec = Mapping[str, Mapping[str, DependencyKind]]
The dependency edges of an AutoStructured guide, keyed first by
child site and then by parent site.
AmortizedGuide
¶
AmortizedGuide(model: MonadicProgram, observed_names: set[str], encoders: Mapping[str, tuple[ContinuousMorphism, str]], *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: Guide
Variational guide that runs encoders on the data.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
The model.
TYPE:
|
observed_names
|
The observed site names, for a registry read off the model.
TYPE:
|
encoders
|
For each latent site the guide covers, the encoder and the name
of the datum (an observation or a host datum) it reads. Other
latent sites are left to another guide, composed with this one
in an
TYPE:
|
x
|
Keyword-only. A program input at which to build the registry
from a run (
TYPE:
|
observations
|
Keyword-only. The data of that run; when given, the guide also
observes them (
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
TypeError
|
If an encoder is not a |
Source code in src/quivers/inference/guides/amortized.py
uncovered_sites
property
¶
The model's latent sites no encoder covers; another guide in an
AutoGuideList must cover them.
observe
¶
observe(observations: Mapping[str, Tensor]) -> None
Take the data the encoders read.
Every objective calls this with the observations of the step it evaluates; call it directly before sampling the guide on other data, such as held-out data.
| PARAMETER | DESCRIPTION |
|---|---|
observations
|
Observed values and host data.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a datum an encoder reads is missing, or an encoder's density is not exact at it. |
Source code in src/quivers/inference/guides/amortized.py
rsample
¶
Draw every bound site from its encoder applied to its datum.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The program input; its rows are the runs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
Trace-side values: |
Source code in src/quivers/inference/guides/amortized.py
log_prob
¶
The guide's log-density of site values, per run.
For a site reached through the bijector :math:T,
:math:\log q(v) = \log e(T^{-1}(v) \mid y) + \log
|\det J_{T^{-1}}(v)|; otherwise :math:\log e(v \mid y).
Each site's value is read per run (LatentSite.align_runs), and
the encoder rows a run reads are its own rows of the datum, or
the rows every run shares when the datum has no run axis. A
plate site's rows add up within a run; under a
subsample block only the subset's
rows do, times the plate's size over the subset's.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The program input.
TYPE:
|
sites
|
Trace-side values of the bound sites, each one per run or one
the runs share (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If a bound site is missing from |
ValueError
|
If a value is neither one per run nor one the runs share. |
Source code in src/quivers/inference/guides/amortized.py
AutoGuideList
¶
AutoGuideList(parts: dict[str, Guide])
Bases: Guide
A block-composed variational guide.
| PARAMETER | DESCRIPTION |
|---|---|
parts
|
Named subguides, each covering a disjoint set of latent
site names. Keys are labels used for parameter-namespacing
and error messages; values are any
TYPE:
|
Source code in src/quivers/inference/guides/auto_guide_list.py
registry
property
¶
The list-guide has no single fused registry; downstream
code that needs one should walk part_labels and pull each
sub-guide's Guide.registry directly.
part
¶
part(label: str) -> Guide
Look up a sub-guide by label.
Source code in src/quivers/inference/guides/auto_guide_list.py
observe
¶
observe(observations: Mapping[str, Tensor]) -> None
Forward the step's data to every part.
| PARAMETER | DESCRIPTION |
|---|---|
observations
|
Observed values and host data.
TYPE:
|
Source code in src/quivers/inference/guides/auto_guide_list.py
rsample
¶
Concatenate per-part reparameterized draws.
Source code in src/quivers/inference/guides/auto_guide_list.py
rsample_strata
¶
Product of the parts' strata.
The parts are independent, so the joint guide's strata are the
Cartesian product of the parts' strata: each joint draw merges
one draw per part and carries the sums of the parts'
log-weights and log-densities. A part that is an
AutoMixtureGuide thus has its components enumerated inside
the list guide, and an AutoDAIS part contributes the density
of its own trajectory.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[GuideDraw, ...]
|
|
Source code in src/quivers/inference/guides/auto_guide_list.py
log_prob
¶
Sum per-part log-densities.
Each sub-guide receives only the site keys it owns; a
missing key raises KeyError in the sub-guide.
Source code in src/quivers/inference/guides/auto_guide_list.py
AutoStructured
¶
AutoStructured(model: MonadicProgram, observed_names: set[str], conditionals: ConditionalSpec, dependencies: DependencySpec | None = None, init_scale: float = 0.1, *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: Guide
Per-site / per-edge structured variational guide.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model to build a guide for.
TYPE:
|
observed_names
|
Variable names treated as observations.
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
conditionals
|
Per-site marginal-family choice. A single string sets every site to the same family. A dict maps site name to family. Allowed families:
TYPE:
|
dependencies
|
Directed edges.
TYPE:
|
init_scale
|
Initial scale of every
TYPE:
|
Source code in src/quivers/inference/guides/auto_structured.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
conditionals
property
¶
Per-site marginal family, as resolved at construction.
dependencies
property
¶
dependencies: dict[str, dict[str, DependencyKind]]
The declared per-edge dependence structure.
rsample
¶
Ancestral reparameterized draw, one shared by every run.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input; its leading axis has one row per run.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
Per-site constrained values: |
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If a site has a conditional kind outside the allowed ones. |
Source code in src/quivers/inference/guides/auto_structured.py
log_prob
¶
Pushforward log-density of each run's constrained values.
For run b, every site's value is inverted through its
bijector (LatentRegistry.unconstrain_runs), each "normal"
site is scored under its Normal at its location shifted by run
b's parent draws, the "mvn" sites are scored jointly, and
every site's inverse-bijector term at run b's value is
added. A "delta" site contributes its bijector term only.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input; its leading axis has one row per run.
TYPE:
|
sites
|
Constrained values of every latent site, each one per run or
one the runs share (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If a latent site is missing from |
ValueError
|
If a value is neither one per run nor one the runs share. |
Source code in src/quivers/inference/guides/auto_structured.py
Guide
¶
Bases: Module, ABC
Abstract variational guide.
Subclasses MUST implement rsample and log_prob
and expose latent_names. They MAY override
registry if they construct their registry lazily, but
the default implementation expects self._registry to be
set in __init__.
scores_subsampled_rows
class-attribute
¶
Whether log_prob scores a latent in a subsampled plate at the
subset's rows, scaled as the model's sites are. A guide whose density
does not split over a plate's rows leaves it False and refuses
such a latent through check_subsampling.
latent_names
abstractmethod
property
¶
Names of latent variables this guide covers.
check_subsampling
¶
Refuse a latent in a subsampled plate this guide cannot score by rows.
Under a subsample block the model
scores a plate's latents at the subset's rows, scaled; the
guide's density must match, or the objective is not an unbiased
estimate of the full one. A guide that scores rows declares
scores_subsampled_rows.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a subsampled plate holds one of the guide's latents and the guide does not score a plate's rows separately. |
Source code in src/quivers/inference/guides/base.py
build_registry
classmethod
¶
build_registry(model: MonadicProgram, observed_names: set[str] | frozenset[str], *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None) -> LatentRegistry
Build the latent registry a guide is constructed against.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
The model.
TYPE:
|
observed_names
|
The names observed, for a registry read off the model's steps.
TYPE:
|
x
|
A program input. When given, the registry is built from a
run of the model at
TYPE:
|
observations
|
The observed values and host data of that run.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LatentRegistry
|
The registry. |
Source code in src/quivers/inference/guides/base.py
observe
¶
observe(observations: Mapping[str, Tensor]) -> None
Receive the data of the step about to sample the guide.
Every objective calls this with its step's observations and host
data before it draws from the guide, so a guide that reads the
data (an AmortizedGuide) samples the posterior of the data the
step scores. A guide whose parameters do not depend on the data
ignores them, as this base implementation does.
| PARAMETER | DESCRIPTION |
|---|---|
observations
|
Observed values and host data.
TYPE:
|
Source code in src/quivers/inference/guides/base.py
rsample
abstractmethod
¶
Reparameterized sample from :math:q_\phi(z \mid x).
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
Per-site constrained samples shaped to match the model's trace-side convention. |
Source code in src/quivers/inference/guides/base.py
rsample_strata
¶
Weighted reparameterized draws from :math:q_\phi(z \mid x).
Returns one GuideDraw per stratum :math:s, with log-weight
:math:\log \omega_s and a draw :math:z_s \sim q_s, such
that the strata partition the guide's density,
:math:q_\phi = \sum_s \omega_s\, q_s with
:math:\sum_s \omega_s = 1. Thus
:math:\sum_s \omega_s f(z_s) is an unbiased estimate of
:math:\mathbb{E}_{q_\phi}[f(z)] for every f, and
:math:\sum_s \omega_s\, p(z_s) / q_\phi(z_s) is an
unbiased estimate of :math:\int p. Each draw carries the guide
log-density the objectives pair it with. Gradients reach the
variational parameters through the reparameterized draws, the
densities, and the log-weights.
The default returns a single draw from rsample with log-weight
zero, scored by log_prob. A guide with a discrete choice inside
its sampler (such as AutoMixtureGuide) overrides it to
enumerate that choice; a guide without a density at arbitrary
points (such as AutoDAIS) overrides it to return the density
of the path that produced the draw.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input, as for
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[GuideDraw, ...]
|
The |
Source code in src/quivers/inference/guides/base.py
log_prob
abstractmethod
¶
Log density of sites under :math:q_\phi(z \mid x), run by run.
An input x of B rows is B independent runs of the
program, and the guide's law :math:q_\phi is a law over the
latents of one run. The value of each site in sites either
has a leading run axis, shape (B, *constrained_shape), with
run b's value at index b, or has shape
LatentSite.constrained_shape and is one value every run
shares; LatentSite.align_runs states the rule, and any other
shape is refused. Entry b of the result is
:math:\log q_\phi(v_b), the log density of run b's
values :math:v_b alone, with the change-of-variables term of
each site's bijector at :math:v_b: it equals the density
log_prob gives with a one-row input and run b's values,
whatever the other runs hold. A shared value thus enters every
run's density in full.
The draws rsample returns for the B runs each follow
:math:q_\phi, but need not be independent of one another: a
guide with one joint draw (AutoMultivariateNormalGuide, a
flow, AutoStructured, AutoLaplaceApproximation) gives every
run the same draw. log_prob scores any values, its own draws
or not.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input; its leading axis has one row per run.
TYPE:
|
sites
|
Constrained values of the sites the guide covers, each one per run or one the runs share.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
Source code in src/quivers/inference/guides/base.py
GuideDraw
didactic-model
¶
GuideDraw(*, sites: dict[str, Tensor] = field(opaque=True, extras=OPAQUE_BY_IDENTITY), log_density: Tensor = field(opaque=True, extras=OPAQUE_BY_IDENTITY), log_weight: Tensor = field(opaque=True, extras=OPAQUE_BY_IDENTITY))
Bases: ValueModel
One weighted draw from a guide, scored by the guide.
The site tensors, density, and weight compare by identity: two draws are equal exactly when they hold the same tensor objects.
| PARAMETER | DESCRIPTION |
|---|---|
sites
|
Per-site constrained values, shaped as
TYPE:
|
log_density
|
The guide log-density of this draw, shape
TYPE:
|
log_weight
|
Scalar log-weight :math:
TYPE:
|
AutoDeltaGuide
¶
AutoDeltaGuide(model: MonadicProgram, observed_names: set[str], init_value: float = 0.0, *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: Guide
Dirac-delta MAP guide with per-site constrained bijector.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model.
TYPE:
|
observed_names
|
Variable names treated as observations.
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
init_value
|
Initial unconstrained-space coordinate for every latent.
Default
TYPE:
|
Notes
The guide's density is constant, so it scores a latent in a
subsampled plate as it scores every
other latent.
Source code in src/quivers/inference/guides/delta.py
rsample
¶
Return the learned point estimates in the prior's support.
Source code in src/quivers/inference/guides/delta.py
log_prob
¶
Delta log-density of each run: zero (the delta term and its Jacobian cancel in the ELBO under the standard score-function trick).
The values are still checked against the run-wise contract of
Guide.log_prob.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input; its leading axis has one row per run.
TYPE:
|
sites
|
Constrained values of every latent site, each one per run or one the runs share.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Zeros of shape |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If a latent site is missing from |
ValueError
|
If a value is neither one per run nor one the runs share. |
Source code in src/quivers/inference/guides/delta.py
AutoIAFGuide
¶
AutoIAFGuide(model: MonadicProgram, observed_names: set[str], num_flows: int = 4, hidden_dim: int | None = None, num_hidden_layers: int = 2, *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: AutoNormalizingFlow
Inverse-autoregressive-flow guide.
Default normalizing-flow guide for variational inference
(Kingma-Salimans-Jozefowicz et al. 2016). Stack of
InverseAutoregressiveTransform layers, each separated
by a reverse permutation so successive layers have different
autoregressive orderings.
Sampling is parallel (one MLP forward per layer); density evaluation is sequential (one coordinate at a time per layer), so this guide should be used with objectives that sample more than they score the same flow (ELBO, IWAE).
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model.
TYPE:
|
observed_names
|
Variable names treated as observations.
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
num_flows
|
Number of IAF blocks in the stack. Default
TYPE:
|
hidden_dim
|
Hidden width of every MADE inside the stack. Default
TYPE:
|
num_hidden_layers
|
Number of hidden layers in each MADE. Default
TYPE:
|
Source code in src/quivers/inference/guides/flow.py
AutoNeuralSplineGuide
¶
AutoNeuralSplineGuide(model: MonadicProgram, observed_names: set[str], num_flows: int = 4, num_bins: int = 8, tail_bound: float = 3.0, hidden_dim: int | None = None, num_hidden_layers: int = 2, *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: AutoNormalizingFlow
Neural-spline-flow guide (Durkan-Bekasov-Murray-Papamakarios 2019).
Stack of monotone rational-quadratic spline coupling layers
(NeuralSplineCouplingTransform) with alternating
half-masks. Sharper than IAF for posteriors with bounded
support or sharp modes; comparable runtime.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model.
TYPE:
|
observed_names
|
Variable names treated as observations.
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
num_flows
|
Number of coupling layers. Default
TYPE:
|
num_bins
|
Number of spline bins per coordinate. Default
TYPE:
|
tail_bound
|
Inputs outside
TYPE:
|
hidden_dim
|
Hidden width of the coupling MLPs. Default
TYPE:
|
num_hidden_layers
|
Hidden layers in each coupling MLP. Default
TYPE:
|
Source code in src/quivers/inference/guides/flow.py
AutoNormalizingFlow
¶
AutoNormalizingFlow(model: MonadicProgram, observed_names: set[str], transforms: list[TransformModule], *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: Guide
Normalising-flow variational guide over the flat latent vector.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model to build a guide for.
TYPE:
|
observed_names
|
Variable names treated as observations.
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
transforms
|
Flow stack applied to the standard-Normal base. Each
TYPE:
|
Source code in src/quivers/inference/guides/flow.py
push_forward
¶
Push base points through the flow.
| PARAMETER | DESCRIPTION |
|---|---|
z0
|
Points of the base space, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Tensor, Tensor]
|
The images :math: |
Source code in src/quivers/inference/guides/flow.py
pull_back
¶
Pull points of the flow's codomain back to the base space.
| PARAMETER | DESCRIPTION |
|---|---|
z_K
|
Points of the codomain, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Tensor, Tensor]
|
The base points :math: |
Source code in src/quivers/inference/guides/flow.py
update_statistics
¶
Refresh every layer's data-dependent state from base draws.
Draws num_draws base points, and walks the stack: each layer
folds the batch of its inputs into its state
(TransformModule.update_statistics) and then maps the batch
on, so a later layer sees the inputs the updated earlier layers
give it. Objectives never call this; call it between steps.
| PARAMETER | DESCRIPTION |
|---|---|
num_draws
|
Number of base draws, at least two.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/inference/guides/flow.py
rsample
¶
One flow draw, unflattened and bijected to constrained space.
Source code in src/quivers/inference/guides/flow.py
log_prob
¶
Log-density of each run's constrained values.
For run b the flat unconstrained point :math:z_{K,b} of its
values, read by LatentRegistry.unconstrain_runs, is pulled back
through the flow, and
:math:\log q(v_b) = \log p_0(z_{0,b}) - \sum_k \log|\det J_{T_k}|
+ \sum_i \log|\det J_{T_i^{-1}}(v_{b,i})|, the last sum over
the per-site bijectors. Every transform in
quivers.inference.transforms
maps each row of the (B, D) matrix of points alone.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input; its leading axis has one row per run.
TYPE:
|
sites
|
Constrained values of every latent site, each one per run or
one the runs share (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If a latent site is missing from |
ValueError
|
If a value is neither one per run nor one the runs share. |
Source code in src/quivers/inference/guides/flow.py
AutoLaplaceApproximation
¶
AutoLaplaceApproximation(model: MonadicProgram, observed_names: set[str], init_value: float = 0.0, *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: Guide
Laplace-approximation guide.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model.
TYPE:
|
observed_names
|
Variable names treated as observations.
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
init_value
|
Initial unconstrained-space MAP estimate. Default
TYPE:
|
Source code in src/quivers/inference/guides/laplace.py
fit_hessian
¶
fit_hessian(model: MonadicProgram, x: Tensor, observations: dict[str, Tensor], *, jitter: float = 0.0001) -> None
Compute and cache the Hessian-derived Cholesky factor.
Solves the eigenproblem of the negative-log-joint Hessian at
the current MAP, projects negative eigenvalues to jitter
(so the resulting Gaussian is always positive-definite), and
stores the matching lower-triangular Cholesky factor of the
inverse Hessian as the posterior scale_tril.
Call this after MAP optimization has converged. Subsequent
rsample / log_prob calls sample from
:math:\mathcal{N}(z^\star, H^{-1}).
| PARAMETER | DESCRIPTION |
|---|---|
model
|
The model whose joint the Hessian is taken of.
TYPE:
|
x
|
Program input: one row, since the approximation is of one run's posterior.
TYPE:
|
observations
|
Observed-site values and host data.
TYPE:
|
jitter
|
The floor every eigenvalue of the Hessian is projected to.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/inference/guides/laplace.py
rsample
¶
Sample from the Laplace posterior, unflatten, and biject.
Source code in src/quivers/inference/guides/laplace.py
log_prob
¶
Log-density of each run's constrained values.
Returns zero for every run before fit_hessian (MAP-phase delta
convention); after fit_hessian returns, for run b, the
Gaussian log-density of run b's flat unconstrained point plus
the per-site bijector Jacobian correction at its values, read by
LatentRegistry.unconstrain_runs.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input; its leading axis has one row per run.
TYPE:
|
sites
|
Constrained values of every latent site, each one per run or
one the runs share (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If a latent site is missing from |
ValueError
|
If a value is neither one per run nor one the runs share. |
Source code in src/quivers/inference/guides/laplace.py
AutoMixtureGuide
¶
AutoMixtureGuide(components: list[Guide])
Bases: Guide
Finite mixture variational guide.
| PARAMETER | DESCRIPTION |
|---|---|
components
|
Component guides. All components must share the same
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If fewer than two components are given, or if the components cover different latent names. |
Source code in src/quivers/inference/guides/mixture.py
num_components
property
¶
Number of mixture components.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The component count :math: |
latent_names
property
¶
Names of the latent sites the mixture covers.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
The registry's site names, in order. |
mixture_weights
¶
mixture_weights() -> Tensor
Mixture weights :math:\pi = \mathrm{softmax}(\text{logits}).
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
Source code in src/quivers/inference/guides/mixture.py
observe
¶
observe(observations: Mapping[str, Tensor]) -> None
Forward the step's data to every component.
| PARAMETER | DESCRIPTION |
|---|---|
observations
|
Observed values and host data.
TYPE:
|
Source code in src/quivers/inference/guides/mixture.py
rsample
¶
Draw from the mixture density that log_prob scores.
Samples a component index :math:k \sim
\mathrm{Categorical}(\pi) and returns component k's
reparameterized draw. One index is drawn per call and shared
across the batch rows, so a plate latent and the per-row
latents of every row come from the same component, matching
the per-row joint density log_prob evaluates.
Gradients reach the chosen component's parameters but not
the mixture logits, since the component choice is discrete.
The variational objectives train the logits through
rsample_strata instead.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
Per-site constrained draws from the mixture. |
Source code in src/quivers/inference/guides/mixture.py
rsample_strata
¶
Enumerate the components as strata.
Each component contributes its own strata (one for an
ordinary component, several for a nested mixture), with the
component's log mixture weight added to their log-weights and
each draw scored by the mixture density. The resulting weights
sum to one and the strata partition the mixture density, so
:math:\sum_s \omega_s f(z_s) estimates
:math:\mathbb{E}_q[f] without bias, with gradients to the
mixture logits through :math:\omega_s and the density.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[GuideDraw, ...]
|
One weighted draw per stratum, |
Source code in src/quivers/inference/guides/mixture.py
log_prob
¶
Mixture log-density via logsumexp over components.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
sites
|
Per-site constrained values to score.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
:math: |
Source code in src/quivers/inference/guides/mixture.py
AutoLowRankMultivariateNormalGuide
¶
AutoLowRankMultivariateNormalGuide(model: MonadicProgram, observed_names: set[str], rank: int = 5, init_scale: float = 0.1, *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: _MVNCommon
Low-rank-plus-diagonal multivariate-Normal guide.
Covariance :math:\Sigma = W W^\top + \mathrm{diag}(\sigma^2)
with W of shape :math:(D, r) and :math:\sigma \in
\mathbb{R}^{D}_{>0}. Memory :math:O(Dr); sampling and
log-density via Woodbury / matrix-determinant lemma in
torch.distributions.LowRankMultivariateNormal.
Captures the dominant r posterior correlation directions
while remaining tractable for D in the hundreds-to-
thousands range, where full-rank is infeasible.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model to build a guide for.
TYPE:
|
observed_names
|
Variable names treated as observations.
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
rank
|
Number of correlated directions. Default
TYPE:
|
init_scale
|
Initial diagonal scale.
TYPE:
|
Source code in src/quivers/inference/guides/multivariate_normal.py
AutoMultivariateNormalGuide
¶
AutoMultivariateNormalGuide(model: MonadicProgram, observed_names: set[str], init_scale: float = 0.1, *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None)
Bases: _MVNCommon
Full-rank multivariate-Normal variational guide.
Parameterises a joint Gaussian over the registry's flat unconstrained vector with a learnable lower-triangular Cholesky factor. Captures every pairwise posterior correlation across every latent site, the right choice when posterior couplings are strong (hierarchical regression with crossed random effects, parameter pairs with multiplicative interaction).
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model to build a guide for.
TYPE:
|
observed_names
|
Variable names treated as observations.
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
init_scale
|
Initial diagonal of the Cholesky factor. Default
TYPE:
|
Source code in src/quivers/inference/guides/multivariate_normal.py
AutoNormalGuide
¶
AutoNormalGuide(model: MonadicProgram, observed_names: set[str], init_scale: float = 0.1, *, x: Tensor | None = None, observations: dict[str, Tensor] | None = None, initial_values: Mapping[str, Tensor | float] | None = None)
Bases: Guide
Mean-field Normal guide with per-site constrained-support bijector.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model to build a guide for.
TYPE:
|
observed_names
|
Variable names treated as observations (skipped in the guide; their values flow through the conditioning data dict at trace time).
TYPE:
|
x
|
Keyword-only. A program input at which to build the latent registry from a run, required for a program that scans or calls a program that draws, whose latent sites depend on its input.
TYPE:
|
observations
|
Keyword-only. The observed values and host data of that run.
TYPE:
|
init_scale
|
Initial scale (in unconstrained space) of every latent.
Default
TYPE:
|
initial_values
|
Optional natural-scale initial centers keyed by latent site. Scalars broadcast to a site's shape; arrays must match it. Values must be strictly inside the site's support. Other centers remain zero in unconstrained space.
TYPE:
|
Notes
The guide factors over a plate's rows, so under a
subsample block log_prob scores a
latent in a subsampled plate at the subset's rows, times the same
factor the model's sites take; every row is still drawn, and the
rows outside the subset receive no gradient from the step.
Source code in src/quivers/inference/guides/normal.py
latent_names
property
¶
Return checked latent names in their registry order.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Site labels, including individual scan occurrences. |
from_registry
classmethod
¶
from_registry(registry: LatentRegistry, *, init_scale: float = 0.1, initial_values: Mapping[str, Tensor | float] | None = None) -> AutoNormalGuide
Initialize parameters against an already checked latent registry.
| PARAMETER | DESCRIPTION |
|---|---|
registry
|
Existing model, site supports, and declared event geometry.
TYPE:
|
init_scale
|
Initial unconstrained Normal scale, as in the ordinary constructor.
TYPE:
|
initial_values
|
Optional natural-scale parameter centers.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AutoNormalGuide
|
A fresh guide without tracing or sampling the model. |
Source code in src/quivers/inference/guides/normal.py
rsample
¶
Draw a reparameterized mean-field Normal-then-bijector sample.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Execution input whose leading axis gives the number of runs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
Values indexed by checked latent names. |
Source code in src/quivers/inference/guides/normal.py
log_prob
¶
Pushforward log-density of each run's constrained values.
Uses the change-of-variables identity, run by run:
log q(v_b) = log Normal(z_b; loc, scale) + log|det J_{T^{-1}}(v_b)|
where z_b = bijector.inv(v_b) is read from
LatentRegistry.unconstrain_runs. A latent in a plate that a
subsample block is active for is
scored at the subset's rows, times the plate's size over the
subset's.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Execution input carrying the leading run axis.
TYPE:
|
sites
|
Constrained latent values to score, each one per run or one
the runs share (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
One variational log density per execution run. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If a latent site is missing from |
ValueError
|
If a value is neither one per run nor one the runs share. |
Source code in src/quivers/inference/guides/normal.py
Latent registry¶
Every guide and MCMC kernel reads the model's latent sites through a
LatentRegistry.
registry
¶
Latent-site registry: the canonical introspection surface that every variational guide and MCMC kernel consumes.
A LatentRegistry is built once from a
quivers.continuous.programs.MonadicProgram and a set of
observed site names. It walks the model's steps linear IR
exactly once, classifies each latent into "plate" vs "scalar",
records the prior support and per-site dimensionality, builds the
matching torch.distributions.transforms.Transform via
torch.distributions.constraint_registry.biject_to, and
caches a fused flatten / unflatten pipeline so a single
unconstrained vector can be turned into a fully constrained site
dict (and back) in one pass.
The registry is the only place in the inference layer that knows
about PlateDraw, the layout
of MonadicProgram.steps, or the per-site
constraint-to-bijector mapping. Every downstream component
(Guide,
MCMCKernel, the
flow-based / structured / mixture guides) receives a fully
populated registry and operates against its flat-vector and
per-site dict APIs.
Categorical interpretation¶
Each latent site corresponds to a draw in the model's Kleisli
arrow Γ → 𝒢(τ). The site's prior is a parameterized family
F : Θ → 𝒢(B) with a support constraint
C ⊆ B. The bijector T : ℝ^d → C is the
biject_to lift of C; its log-determinant gives the
change-of-variables term in any pushforward density.
For a plate v : A → B the latent lives in C^|A|; the
registry handles the leading plate axis (size |A|) separately
from the trailing event axis (the support dimension), and the
unconstrained flat vector concatenates plate × event across every
site in declaration order.
ReducedSupport
¶
Bases: Protocol
A support with fewer free coordinates than its constrained vector.
unconstrained_dim
¶
Count the free coordinates of a constrained vector.
| PARAMETER | DESCRIPTION |
|---|---|
constrained_dim
|
Length of the constrained vector.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Number of free coordinates. |
Source code in src/quivers/inference/registry.py
LatentSite
didactic-model
¶
LatentSite(*, name: str, morphism: ContinuousMorphism = field(opaque=True, extras=OPAQUE_BY_IDENTITY), support: Constraint = field(opaque=True, extras=OPAQUE_BY_IDENTITY), bijector: Transform = field(opaque=True, extras=OPAQUE_BY_IDENTITY), constrained_dim: int, unconstrained_dim: int, is_plate: bool, plate_index_size: int, spec_index: int, flat_offset: int, flat_length: int, plate_shape: tuple[int, ...] = (), event_shape: tuple[int, ...] = ())
Bases: ValueModel
Frozen record describing a single latent site.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Variable name (the bound name in the program body).
TYPE:
|
morphism |
The site's runtime morphism (the prior). Held by reference
so guides / kernels can call
TYPE:
|
support |
Support of the prior. Drives the choice of bijector.
TYPE:
|
bijector |
TYPE:
|
constrained_dim |
Event dimension on the constrained side (for a scalar
site,
TYPE:
|
unconstrained_dim |
Event dimension on the unconstrained side (for a Dirichlet
on a 5-simplex,
TYPE:
|
is_plate |
Whether this site is a plate draw
(
TYPE:
|
plate_index_size |
TYPE:
|
spec_index |
Position in
TYPE:
|
flat_offset |
Index of this site's first element in the registry's flat unconstrained vector.
TYPE:
|
flat_length |
Number of elements this site occupies in the flat vector
(=
TYPE:
|
plate_shape |
The extents of a plate site's axes, outermost first, whose
product is
TYPE:
|
event_shape |
Declared intrinsic event axes, including rectangular matrix events. Empty retains the legacy scalar/support-derived geometry.
TYPE:
|
is_scalar
property
¶
Whether one constrained event is a scalar, rather than a singleton tensor.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True only for a one-coordinate support without intrinsic event axes. Singleton simplices and matrices retain their event axes. |
constrained_shape
property
¶
The shape of one draw of this site on its constrained support after the bijector. Scalar supports omit an event axis; singleton simplex and matrix supports retain theirs.
Plate sites have shape (*plate_shape,) or
(*plate_shape, d), (|A|,) or (|A|, d) for a plate
over one axis; non-plate
sites have shape () for a scalar event and (d,)
otherwise. Posterior containers index draws by this shape:
MCMCResult.samples holds (num_chains, num_samples,
*constrained_shape) and MCMCResult.r_hat and
MCMCResult.ess hold constrained_shape.
The values a program's MonadicProgram.log_joint, a trace,
and a guide exchange carry the run axis of the program's input,
whose B rows are B independent runs: a non-plate site
is (B, *constrained_shape) ((1, *constrained_shape) in
one run), and a plate site is constrained_shape in one run,
or one value every run shares, and (B, *constrained_shape)
given or recorded per run. LatentRegistry.trace_values lifts
one draw to the values runs share.
A correlation-Cholesky site's draw is a lower-triangular
(d, d) factor and a positive-definite site's a (d, d)
matrix, so its event shape is (d, d) rather
than (d,).
unconstrained_shape
property
¶
The variational-side shape of this site's value in unconstrained space (before the bijector).
constrain
¶
Map flat site coordinates to the declared structured event.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Site unconstrained coordinates, optionally preceded by sample/run axes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Tensor, Tensor]
|
Structured constrained values and the transform-native log Jacobian. Only support event axes are reduced by an event-aware transform. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the trailing coordinates disagree with the declared site layout. |
Source code in src/quivers/inference/registry.py
unconstrain
¶
Invert a declared structured event into flat site coordinates.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Constrained event, optionally preceded by sample/run axes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Tensor, Tensor]
|
Flat site coordinates and the transform-native inverse log Jacobian. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the event's trailing axes disagree with its declared shape. |
Source code in src/quivers/inference/registry.py
align_runs
¶
Give a trace-side value of this site one entry per run.
The values a program's log joint, a trace, and a guide exchange
for an input of runs rows take one of two shapes. A value of
shape (runs, *constrained_shape) holds one value per run,
run b at index b. A value of shape constrained_shape
has no run axis and is one value every run shares, as a plate
latent drawn once is. No other shape is a value of the site:
in particular a run axis of size one does not stand for
runs runs.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The site's value, shared by every run or given per run.
TYPE:
|
runs
|
The number of runs, the rows of the program input.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/inference/registry.py
unconstrain_runs
¶
Map a trace-side value to unconstrained coordinates, run by run.
The value is aligned to the run axis (align_runs) and passed
through the inverse bijector. The inverse Jacobian term is
summed over each element's event axes and kept apart for every
run and, for a plate site, every plate element, so a guide can
score each run alone and each plate row alone.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The site's value, shared by every run or given per run.
TYPE:
|
runs
|
The number of runs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Tensor, Tensor]
|
The coordinates, shape |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the value is not a value of the site, or the bijector's Jacobian term does not keep the run axis and the plate's elements apart. |
Source code in src/quivers/inference/registry.py
RunCoordinates
didactic-model
¶
RunCoordinates(*, runs: int, unconstrained: dict[str, Tensor] = field(opaque=True, extras=OPAQUE_BY_IDENTITY), log_abs_det: dict[str, Tensor] = field(opaque=True, extras=OPAQUE_BY_IDENTITY))
Bases: ValueModel
The latent values of several runs in unconstrained coordinates.
Built by LatentRegistry.unconstrain_runs, which applies
LatentSite.unconstrain_runs to every site.
| PARAMETER | DESCRIPTION |
|---|---|
runs
|
The number of runs.
TYPE:
|
unconstrained
|
Each site's coordinates, shape
TYPE:
|
log_abs_det
|
Each site's inverse-bijector term
:math:
TYPE:
|
total_log_abs_det
¶
total_log_abs_det() -> Tensor
The inverse-bijector term of each run, summed over its sites.
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
Source code in src/quivers/inference/registry.py
LatentRegistry
¶
LatentRegistry(sites: dict[str, LatentSite], observed_names: frozenset[str], model: MonadicProgram)
The complete introspection result for one (model, observed-set) pair.
Constructed once via from_model; immutable thereafter.
Provides:
- Iteration over latent sites in declaration order
(
sites,plate_sites,scalar_sites). - Total unconstrained dimensionality
(
total_unconstrained_dim), the dim of the flat vector HMC and full-rank Gaussian guides operate on. - Round-tripping between a flat unconstrained vector and a
dict of constrained per-site tensors
(
unflatten_unconstrained,flatten_constrained). - Bijector forward / inverse with Jacobian accumulation
(
to_constrained,to_unconstrained). - Conversion between one draw per site, at
LatentSite.constrained_shape, and the trace-side values a program'slog_jointand the guides exchange, which add the(batch, ...)axis to non-plate sites (trace_values,trace_row).
All operations are vectorized, with no per-site Python loops on the hot path beyond the construction-time setup.
Source code in src/quivers/inference/registry.py
sites
property
¶
sites: dict[str, LatentSite]
Every latent site, keyed by name, in declaration order.
plate_sites
property
¶
plate_sites: dict[str, LatentSite]
The subset of sites that are PlateDraw-shaped.
scalar_sites
property
¶
scalar_sites: dict[str, LatentSite]
The subset of sites that are not plates.
observed_names
property
¶
The observed-name set used to build this registry.
total_unconstrained_dim
property
¶
Sum of every site's flat-vector length.
This is the dim of the unconstrained vector that full-rank Gaussian guides and HMC operate on.
from_model
classmethod
¶
from_model(model: MonadicProgram, observed_names: set[str] | frozenset[str]) -> 'LatentRegistry'
Walk model.steps and assemble the registry.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Compiled probabilistic program.
TYPE:
|
observed_names
|
Variable names treated as observations. Sample sites with names in this set are skipped (their values come from the conditioning data dict at trace time, not from a guide). An observation of an earlier lexical binding is also skipped: its value is computed by the model, rather than supplied by a guide.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LatentRegistry
|
Fully populated registry with each latent's morphism, support, bijector, dims, and flat-vector offsets. |
Source code in src/quivers/inference/registry.py
from_trace
classmethod
¶
from_trace(model: MonadicProgram, recorded: Trace, *, exclude: frozenset[str] | set[str] = frozenset()) -> 'LatentRegistry'
Assemble the registry from a run of the model.
Every sample site the run reached that is neither observed nor
intervened on is a latent, in the order the run reached it. A
site a scan reaches once per position is one latent per
position, "<label>@<n>", so a scanned program cell's latent
trajectory is inferred site by site, as many as the input's
sequence has positions. Build recorded with
trace(model, x, observations) at the input and data the
latents are inferred at.
Sites named in exclude are left out: they are latent, but
held outside the flat vector, as the sites a GibbsKernel
updates are, and they need not have a support the registry can
biject onto (a discrete site, for instance).
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Compiled probabilistic program.
TYPE:
|
recorded
|
A trace of one run of
TYPE:
|
exclude
|
Latent sites to leave out of the registry.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LatentRegistry
|
Fully populated registry with each admitted latent's morphism, support, bijector, dims, and flat-vector offsets. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a structured latent is neither observed nor explicitly excluded. A finite term has no Euclidean coordinates for this registry's continuous estimators. |
Source code in src/quivers/inference/registry.py
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | |
unflatten_unconstrained
¶
Reshape a flat unconstrained vector into per-site unconstrained tensors.
| PARAMETER | DESCRIPTION |
|---|---|
vec
|
Shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
|
Source code in src/quivers/inference/registry.py
flatten_unconstrained
¶
Concatenate per-site unconstrained tensors into a single flat vector.
Inverse of unflatten_unconstrained (up to leading
batch axes). The trailing batch axes of every site tensor
must agree.
Source code in src/quivers/inference/registry.py
unconstrain_runs
¶
unconstrain_runs(sites: dict[str, Tensor], runs: int) -> RunCoordinates
Map the trace-side values of runs runs to unconstrained coordinates.
This is the one place a guide reads site values per run. Each
site's value is aligned to the run axis and inverted through
its bijector (LatentSite.unconstrain_runs), so run b of
the result depends only on run b of every value, or on a
value the runs share. Every guide whose density is over the
registry's coordinates scores sites from this result, and
LatentRegistry.flatten_unconstrained of its coordinates is
the (runs, total_unconstrained_dim) matrix whose row b
is run b's flat point.
| PARAMETER | DESCRIPTION |
|---|---|
sites
|
Trace-side values of every latent site; keys that name no latent site are ignored.
TYPE:
|
runs
|
The number of runs, the rows of the program input.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RunCoordinates
|
Each site's coordinates and inverse-bijector terms, per run. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If a latent site is missing from |
ValueError
|
If a value is neither one per run nor one the runs share. |
Source code in src/quivers/inference/registry.py
to_constrained
¶
Push every site's unconstrained value through its bijector.
| RETURNS | DESCRIPTION |
|---|---|
constrained
|
Per-site constrained values shaped according to
TYPE:
|
log_abs_dets
|
Per-site
TYPE:
|
Source code in src/quivers/inference/registry.py
to_unconstrained
¶
Inverse of to_constrained.
Source code in src/quivers/inference/registry.py
trace_values
¶
Lift single constrained draws to trace-side values.
A trace-side value is what MonadicProgram.log_joint, a
trace, and Guide.rsample exchange: each non-plate site
carries the program's leading batch axis, shape
(batch_size, *constrained_shape), and each plate site
keeps constrained_shape. The lift expands the one draw
across the batch axis, so every input row sees the same
latent value.
| PARAMETER | DESCRIPTION |
|---|---|
constrained
|
One draw per latent site, each of shape
TYPE:
|
batch_size
|
Size of the program input's leading batch axis.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
The trace-side values, keyed as |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/inference/registry.py
trace_draw
¶
One draw per latent site, at its constrained shape, from a run.
A site a destructuring draw binds takes its share of the draw's value, split evenly along the last axis.
| PARAMETER | DESCRIPTION |
|---|---|
run
|
A trace of one run of the model.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
Each latent site's value at |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the run did not reach a latent site. |
Source code in src/quivers/inference/registry.py
trace_row
¶
Read one draw per latent site out of trace-side values.
The inverse of trace_values for one batch row: each
non-plate site, of shape (batch, *constrained_shape),
contributes its row row, and each plate site, of shape
constrained_shape, is returned as is. A guide's
Guide.rsample output is a valid input.
| PARAMETER | DESCRIPTION |
|---|---|
trace_side
|
Trace-side values for every latent site. Keys that name no latent site are ignored.
TYPE:
|
row
|
Index into the batch axis of the non-plate sites.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
One draw per latent site, each of shape
|
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If a latent site is missing from |
ValueError
|
If a site's value is not trace-side shaped, or |
Source code in src/quivers/inference/registry.py
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 | |
aggregate_log_abs_det
staticmethod
¶
aggregate_log_abs_det(log_abs_dets: dict[str, Tensor], leading_shape: tuple[int, ...] = ()) -> Tensor
Sum every per-site log_abs_det over its event axes
and produce a single tensor broadcast to leading_shape.
This is the canonical aggregation an ELBO needs. Objectives that want particle-aware or per-site granularity can skip this helper and aggregate themselves.
Source code in src/quivers/inference/registry.py
zero_unconstrained
¶
zero_unconstrained(*, leading_shape: tuple[int, ...] = (), device: device | None = None, dtype: dtype | None = None) -> dict[str, Tensor]
Return a dict of zero-initialized unconstrained site tensors with the supplied leading batch shape.
Useful for HMC chain initialisation and AutoLaplace's MAP starting point.
Source code in src/quivers/inference/registry.py
randn_unconstrained
¶
randn_unconstrained(*, leading_shape: tuple[int, ...] = (), device: device | None = None, dtype: dtype | None = None, scale: float = 1.0) -> dict[str, Tensor]
Standard-normal-initialized unconstrained site tensors.
Source code in src/quivers/inference/registry.py
Flow transforms¶
The learnable bijections that AutoNormalizingFlow and its subclasses
stack. A custom flow subclasses TransformModule.
transforms
¶
Bijector and normalizing-flow primitives.
This module collects the differentiable bijections quivers's
variational guides chain through. Every primitive is a subclass
of torch.distributions.transforms.Transform, so they
compose under torch.distributions.transforms.ComposeTransform,
plug into torch.distributions.transforms.biject_to-style
pipelines, and interop cleanly with
torch.distributions.transformed_distribution.TransformedDistribution.
Coverage¶
AffineCouplingTransform: RealNVP coupling layer (Dinh, Sohl-Dickstein, Bengio 2017,doi:10.48550/arXiv.1605.08803 <https://doi.org/10.48550/arXiv.1605.08803>_). Splits the input into two halves, scales / shifts one half conditional on the other.MaskedAutoregressiveTransform: MAF (Papamakarios, Pavlakou, Murray 2017,doi:10.48550/arXiv.1705.07057 <https://doi.org/10.48550/arXiv.1705.07057>_). Forward pass is parallel (single masked MLP call); inverse is sequential (per-coordinate). The mass-density form used by variational inference.InverseAutoregressiveTransform: IAF (Kingma, Salimans, Jozefowicz et al. 2016,doi:10.48550/arXiv.1606.04934 <https://doi.org/10.48550/arXiv.1606.04934>_). The dual of MAF: sampling is parallel, density evaluation is sequential. Preferred when you sample more often than score (which is true for variational guides).NeuralSplineCouplingTransform: monotone rational-quadratic spline coupling (Durkan, Bekasov, Murray, Papamakarios 2019,doi:10.48550/arXiv.1906.04032 <https://doi.org/10.48550/arXiv.1906.04032>_). Allows nonlinear monotone transformations within each coupling layer. Expressiveness depends on the spline and network configuration.LULinearTransform: LU-decomposed linear permutation (Kingma, Dhariwal 2018 Glow,doi:10.48550/arXiv.1807.03039 <https://doi.org/10.48550/arXiv.1807.03039>_). Cheap learnable invertible linear layer; the standard inter- coupling-layer mixer.BatchNormTransform: normalization by running moments as a normalizing-flow transform, after Dinh, Sohl-Dickstein, Bengio (2017, the RealNVP paper); the moments are updated explicitly, so the layer is one bijection between updates.
Every primitive is fully implemented (forward, inverse,
log_abs_det_jacobian). No primitive raises NotImplementedError
under any input its type signature accepts. The masked-network
factories are designed so callers can pass a callable / module
rather than configuring topology through string flags.
TransformModule
¶
Cooperative base for transforms that also need to register
torch.nn.Parameter and torch.nn.Module.register_buffer
attributes.
torch.distributions.transforms.Transform is not a
torch.nn.Module, so subclassing both is required for
any flow primitive that holds learnable parameters or buffers
(every primitive in this module). The cooperative base calls
both __init__\ s in MRO order, nn.Module first
so attribute storage is set up before Transform
populates the cache-size machinery.
Source code in src/quivers/inference/transforms.py
update_statistics
¶
update_statistics(inputs: Tensor) -> None
Fold a batch of this layer's inputs into its data-dependent state.
A layer whose map is fixed by statistics of its inputs (a
BatchNormTransform) overrides this; the layer's map is the
same bijection before and after every call of its forward,
inverse, and log-determinant, and changes only here. A layer
without such state has nothing to update, which this default
states.
| PARAMETER | DESCRIPTION |
|---|---|
inputs
|
Points of the layer's domain, shape
TYPE:
|
Source code in src/quivers/inference/transforms.py
AffineCouplingTransform
¶
Bases: TransformModule
RealNVP-style affine coupling transform.
Splits the input vector into two parts: an "identity" part
x_a and a "transformed" part x_b. The transformed part
is shifted and scaled by parameters output from a neural
network that sees only the identity part. The Jacobian is
triangular, so its log-determinant is the sum of the log-scales
on x_b.
| PARAMETER | DESCRIPTION |
|---|---|
dim
|
Total event dimension.
TYPE:
|
net
|
Module mapping
TYPE:
|
mask
|
Boolean mask of shape
TYPE:
|
Source code in src/quivers/inference/transforms.py
MADE
¶
MADE(dim: int, n_per_dim: int, *, hidden: int = 64, n_hidden_layers: int = 2, ordering: Tensor | None = None)
Bases: Module
Masked Autoencoder for Distribution Estimation (Germain, Gregor, Murray, and Larochelle 2015) Germain et al. (2015).
Outputs n_per_dim parameters per input coordinate. The
masking guarantees that output parameters for coordinate j
depend only on input coordinates < j in the supplied
ordering, which is the autoregressive property MAF / IAF
exploit.
Source code in src/quivers/inference/transforms.py
MaskedAutoregressiveTransform
¶
MaskedAutoregressiveTransform(made: MADE)
Bases: TransformModule
Masked Autoregressive Flow (MAF) layer.
Forward (density) is parallel, one MADE call. Inverse (sampling) is sequential in the autoregressive order.
| PARAMETER | DESCRIPTION |
|---|---|
made
|
Masked network producing per-coordinate
TYPE:
|
Source code in src/quivers/inference/transforms.py
InverseAutoregressiveTransform
¶
InverseAutoregressiveTransform(made: MADE)
Bases: TransformModule
Inverse Autoregressive Flow (IAF) layer.
Dual of MaskedAutoregressiveTransform: sampling
(forward) is parallel, density (inverse) is sequential. The
preferred direction for variational guides because we sample
more often than we score.
| PARAMETER | DESCRIPTION |
|---|---|
made
|
Masked network producing per-coordinate
TYPE:
|
Source code in src/quivers/inference/transforms.py
NeuralSplineCouplingTransform
¶
NeuralSplineCouplingTransform(dim: int, net: Module, mask: Tensor, *, num_bins: int = 8, tail_bound: float = 3.0)
Bases: TransformModule
Monotone rational-quadratic spline coupling (Durkan-Bekasov-Murray-Papamakarios 2019).
Same coupling structure as AffineCouplingTransform,
but the per-coordinate transform on x_b is a monotone
rational-quadratic spline rather than an affine map. The
network outputs (unnormalized_widths, unnormalized_heights,
unnormalized_derivatives) per transformed coordinate;
num_bins knots per coordinate.
| PARAMETER | DESCRIPTION |
|---|---|
dim
|
Event dimension.
TYPE:
|
net
|
Maps
TYPE:
|
mask
|
Boolean mask of shape
TYPE:
|
num_bins
|
Number of spline knots.
TYPE:
|
tail_bound
|
Domain of the spline; outside
TYPE:
|
Source code in src/quivers/inference/transforms.py
LULinearTransform
¶
LULinearTransform(dim: int, perm: Tensor | None = None)
Bases: TransformModule
Invertible linear layer parameterized as :math:A = P L U
(Kingma & Dhariwal 2018 Glow).
The unit-lower-triangular L and unit-upper-triangular U
factors are stored along with their respective off-diagonal
weights; the diagonal of U is stored as a log-scale so the
layer remains invertible and the log-determinant is the sum
of the log-scales. P is a fixed permutation chosen at
construction.
Source code in src/quivers/inference/transforms.py
BatchNormTransform
¶
Bases: TransformModule
Normalization by running moments as a normalizing-flow layer.
The layer is the coordinatewise affine bijection
.. math::
T(x) = \frac{x - m}{\sqrt{v + \epsilon}}\, e^{\gamma} + \beta,
\qquad
\log|\det J_T(x)| = \sum_i \bigl(\gamma_i
- \tfrac12 \log(v_i + \epsilon)\bigr),
with learned :math:\gamma, \beta and the running moments
:math:m, v (buffers). Forward, inverse, and log-determinant use the
same :math:m, v, so they are one bijection, and each row of a
(..., dim) input is mapped alone: a flow guide built on the layer
has a density for each run that does not depend on the other runs.
The normalization of Dinh, Sohl-Dickstein, and Bengio (2017),
Density estimation using Real NVP,
uses the moments of the current minibatch in training. That map
changes with the minibatch, so its "density" of one point depends on
the other points scored with it and is not the density of any law
over one run; an objective built from it is not the objective of a
guide. The layer does not compute it, and torch.nn.Module.train
does not change the map. The moments are instead data-dependent
state, folded in by update_statistics from a batch of the layer's
inputs, between objective evaluations
(AutoNormalizingFlow.update_statistics does this for every layer
of a flow guide). Each evaluation is then the objective of the guide
at the current moments, and an update moves the guide as a parameter
update outside the gradient does.
| PARAMETER | DESCRIPTION |
|---|---|
dim
|
Number of coordinates.
TYPE:
|
momentum
|
Weight of a new batch's moments in the running moments, in
TYPE:
|
eps
|
The constant :math:
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/inference/transforms.py
update_statistics
¶
update_statistics(inputs: Tensor) -> None
Fold the moments of a batch of inputs into the running moments.
:math:m \leftarrow (1 - \mu) m + \mu \bar x and
:math:v \leftarrow (1 - \mu) v + \mu s^2, with
:math:\bar x and :math:s^2 the mean and the (biased)
variance of the batch per coordinate and :math:\mu the
momentum, outside the gradient.
| PARAMETER | DESCRIPTION |
|---|---|
inputs
|
Points of the layer's domain, shape
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/inference/transforms.py
make_coupling_mlp
¶
make_coupling_mlp(n_in: int, n_out: int, *, hidden: int = 64, n_hidden_layers: int = 2, activation: type[Module] = ReLU) -> Module
Build an MLP for use as the net argument of
AffineCouplingTransform or
NeuralSplineCouplingTransform.
The output layer is initialized to zero so the transform starts as the identity, which is a standard normalizing-flow initialisation (see Glow, Real NVP).
Source code in src/quivers/inference/transforms.py
alternating_mask
¶
alternating_mask(dim: int, *, even: bool = True) -> Tensor
Boolean mask alternating True / False. Even-indexed
entries are True when even=True.
Source code in src/quivers/inference/transforms.py
Annealed importance sampling¶
dais
¶
Differentiable annealed importance sampling (DAIS) guide.
DAIS runs a short chain of uncorrected Hamiltonian transitions from a
base guide :math:q_0 toward the posterior and uses the chain's
endpoint as the variational draw (Zhang, Hsu, Li, Finn and Grosse
2021; Geffner and Domke 2021). Transition :math:k draws a fresh
momentum :math:v_{k-1} \sim \mathcal{N}(0, I) and applies leapfrog
steps on the bridge :math:\pi_k \propto q_0^{1-\beta_k} p^{\beta_k},
ending at :math:(u_k, \hat v_k); there is no Metropolis correction.
The step sizes, the inverse-temperature schedule :math:\beta_k, and
the base guide's parameters are all variational parameters, and the
whole trajectory is differentiated through, including the bridge
gradients inside each leapfrog step.
Leapfrog is volume preserving, so the forward chain over
:math:(u_0, v_0, \dots, v_{K-1}) and its time reversal define the
extended-space importance weight (Zhang et al. 2021, Eq. 15)
.. math::
\log w = \log p(u_K, y) - \log q_0(u_0)
+ \sum_{k=1}^{K} \bigl[\log \mathcal{N}(\hat v_k)
- \log \mathcal{N}(v_{k-1})\bigr],
with densities taken in the unconstrained space where the chain runs
(each including its bijector's log-Jacobian). Its expectation under
the forward chain is :math:\mathbb{E}[w] = p(y), so
:math:\mathbb{E}[\log w] \le \log p(y) is a valid lower bound
and the multi-sample objectives built from w are valid bounds as
well. The bridges and step sizes shape the chain, not the validity of
the bound; an uncorrected chain does not leave the bridges invariant,
so the AIS weight :math:\sum_k (\beta_k - \beta_{k-1})
(\log p - \log q_0) evaluated along it would not be a valid bound and
is not used. The bound is not guaranteed to improve on the base guide's
ELBO, and a fitted run need not recover every posterior mode.
AutoDAIS.rsample_strata returns the endpoint together with its
extended-space log-density
:math:\log q_0(u_0) - \log|J(u_K)| + \sum_k [K(\hat v_k) - K(v_{k-1})]
(:math:K the kinetic energy), so that log p - log q for the
draw is exactly :math:\log w. The endpoint has no closed-form
marginal density, so AutoDAIS.log_prob raises: the estimators and
objectives that need the guide density at a fixed point
(StickingTheLanding, DoublyReparameterized, ScoreFunction,
RWS) are not available with this guide; use the reparameterized
estimator.
References: Zhang, Hsu, Li, Finn and Grosse (2021), Differentiable Annealed Importance Sampling and the Perils of Gradient Noise; Geffner and Domke (2021), MCMC Variational Inference via Uncorrected Hamiltonian Annealing.
AutoDAIS
¶
AutoDAIS(base: Guide, model: MonadicProgram, observations: dict[str, Tensor], x: Tensor | None = None, num_steps: int = 8, leapfrog_steps: int = 1, init_step_size: float = 0.1, init_temperature: float = 0.1)
Bases: Guide
Annealed-importance-sampling guide wrapping a base guide.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
Base variational guide (the chain's start). Must be built
against the same model + observed-name set the DAIS guide
is for, and must have a density at arbitrary points.
TYPE:
|
model
|
Generative model. Required because the bridges need the target log-density.
TYPE:
|
observations
|
Observed-site values that pin the model's likelihood in the bridges. They shape the dynamics only: the bound that an objective evaluates uses that objective's own input and observations, and is valid for any of them, though the chain is tuned for these.
TYPE:
|
x
|
Program input fed to the model's log-joint inside the bridges:
one row, since the bridges target one run's posterior. Default
TYPE:
|
num_steps
|
Number of Hamiltonian transitions along the path; at least 1.
Default
TYPE:
|
leapfrog_steps
|
Leapfrog substeps per transition. Default
TYPE:
|
init_step_size
|
Initial leapfrog step size, one learnable value per transition.
TYPE:
|
init_temperature
|
Initial first inverse temperature, in
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/inference/dais.py
latent_names
property
¶
Names of the latent sites the guide covers.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
The registry's site names, in order. |
observe
¶
observe(observations: Mapping[str, Tensor]) -> None
Forward the step's data to the base guide.
| PARAMETER | DESCRIPTION |
|---|---|
observations
|
Observed values and host data.
TYPE:
|
Source code in src/quivers/inference/dais.py
rsample
¶
Endpoint of one annealed trajectory, as trace-side values.
One trajectory is run per call and shared by every row of
x's batch axis. The endpoint has no closed-form density, so
objectives draw through rsample_strata, which returns the
trajectory's density with the draw.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
Non-plate sites at |
Source code in src/quivers/inference/dais.py
rsample_strata
¶
One trajectory's endpoint with its extended-space density.
The draw's log_density is the extended-space log-density of
the trajectory that produced it, so for a model and input whose
log-joint at the endpoint is :math:\log p(z_K, y), the value
log p - log_density is the trajectory's DAIS log-weight
:math:\log w, and ELBO estimates
:math:\mathbb{E}[\log w] \le \log p(y). Each call runs a
fresh trajectory, so several particles are independent.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[GuideDraw, ...]
|
A single draw with log-weight zero; its density is
expanded to |
Source code in src/quivers/inference/dais.py
log_prob
¶
Refuse: the DAIS endpoint has no density at arbitrary sites.
The endpoint's marginal density integrates over every momentum
draw of the trajectory and has no closed form. Its
extended-space density is defined only for the trajectory that
produced a draw and is returned with the draw by
rsample_strata, which the objectives use.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input.
TYPE:
|
sites
|
Site values to score.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Never returns. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
Always. |
Source code in src/quivers/inference/dais.py
Cited sources¶
Pyro Developers. SVI part I: an introduction to stochastic variational inference in Pyro. Pyro Tutorials, version 1.9.1, n.d.-g. URL: https://pyro.ai/examples/svi_part_i.html (visited on 2026-11-06).
David M. Blei, Alp Kucukelbir, and Jon D. McAuliffe. Variational Inference: A Review for Statisticians. Journal of the American Statistical Association, 112(518):859–877, 2017. URL: https://doi.org/10.1080/01621459.2017.1285773, doi:10.1080/01621459.2017.1285773.
Matthew D. Hoffman, David M. Blei, Chong Wang, and John Paisley. Stochastic Variational Inference. Journal of Machine Learning Research, 14(40):1303–1347, 2013. URL: https://www.jmlr.org/papers/v14/hoffman13a.html.
David J. C. MacKay. Information Theory, Inference, and Learning Algorithms. Cambridge University Press, 2003. ISBN 9780521642989. URL: https://assets.cambridge.org/97805216/42989/frontmatter/9780521642989_frontmatter.pdf.
Luke Tierney and Joseph B. Kadane. Accurate Approximations for Posterior Moments and Marginal Densities. Journal of the American Statistical Association, 81(393):82–86, 1986. URL: https://www.tandfonline.com/doi/abs/10.1080/01621459.1986.10478240, doi:10.1080/01621459.1986.10478240.
Mathieu Germain, Karol Gregor, Iain Murray, and Hugo Larochelle. MADE: Masked Autoencoder for Distribution Estimation. In Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, 881–889. 2015. URL: https://proceedings.mlr.press/v37/germain15.html.
Diederik P. Kingma and Prafulla Dhariwal. Glow: Generative Flow with Invertible 1x1 Convolutions. In Advances in Neural Information Processing Systems, volume 31. 2018. URL: https://proceedings.neurips.cc/paper/2018/hash/d139db6a236200b21cc7f752979132d0-Abstract.html.