Bijectors¶
A bijector is an invertible differentiable map with its log Jacobian determinant
(normalizing flows). Exponentiation, for
instance, maps an unconstrained real to a positive value. A change of coordinates changes density
per unit volume, so a density computed through a bijector needs the
Jacobian correction
(Rezende and Mohamed, 2015; Stan Development Team, n.d.-f). Families use bijectors to map their unconstrained
parameters onto their supports, and the TransformReparam strategy uses
them to reparameterize a site.
bijectors
¶
Bijector library for the compositional measure algebra.
A Bijector is a measurable bijection \(f: X \to Y\) between Borel
spaces, together with its inverse \(f^{-1}\) and the log-determinant
of its Jacobian. Pushing forward a measure \(\mu\) along \(f\) produces
a new measure \(f_*\mu\) with density
In log-space (the only sane computational discipline; see
TensorFlow Probability's Bijector rationale):
Every bijector exposes:
forward(x)evaluating \(f\),inverse(y)evaluating \(f^{-1}\),forward_log_det_jacobian(x)evaluating \(\log\bigl|\det J_f(x)\bigr|\),inverse_log_det_jacobian(y)evaluating \(\log\bigl|\det J_{f^{-1}}(y)\bigr|\) (equal to \(-\text{forward\_log\_det\_jacobian}(f^{-1}(y))\) when both are finite).
The library is closed under composition via Compose(b1, b2) and
under inversion via Inverse(b), so the family forms a groupoid
of measurable isomorphisms.
BIJECTORS_BY_NAME
module-attribute
¶
BIJECTORS_BY_NAME: Mapping[str, type[Bijector]] = MappingProxyType({'Identity': IdentityBijector, 'Exp': ExpBijector, 'Log': LogBijector, 'Sigmoid': SigmoidBijector, 'Logit': LogitBijector, 'Softplus': SoftplusBijector, 'StickBreaking': StickBreakingBijector})
The bijectors a QVR source names by their surface spelling.
Pushforward(base, Exp) resolves Exp here. Only bijectors that
take no arguments are listed; an affine or composite map is built in
Python and passed as a value.
Bijector
¶
Bases: ABC
Abstract base for measurable bijections used in
Pushforward.
Implementations override the four primitive methods; the
__call__, Compose, and inv helpers compose them.
forward_shape
¶
inverse_shape
¶
select_batch
¶
Select declared parameter batches while retaining intrinsic event axes.
| PARAMETER | DESCRIPTION |
|---|---|
batch_shape
|
Broadcast batch of the measure before transformation.
TYPE:
|
active
|
Boolean selection over that batch.
TYPE:
|
event_shape
|
Intrinsic coordinates to retain within each selected row.
TYPE:
|
output_shape
|
Optional shape for the selected batch axes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Bijector
|
Transformation with matching selected parameter rows. |
| RAISES | DESCRIPTION |
|---|---|
NotImplementedError
|
If a custom transformation declares no batch-selection capability. |
Source code in src/quivers/continuous/bijectors.py
inverse_log_det_jacobian
¶
Default implementation: invert the forward Jacobian's log-determinant. Subclasses with a more numerically stable closed form should override.
Source code in src/quivers/continuous/bijectors.py
InverseBijector
¶
InverseBijector(base: Bijector)
Bases: Bijector
The inverse of a bijector, deferring all four primitives to the wrapped instance with their roles swapped.
Source code in src/quivers/continuous/bijectors.py
forward_shape
¶
inverse_shape
¶
select_batch
¶
Select the wrapped transformation before taking its inverse.
| PARAMETER | DESCRIPTION |
|---|---|
batch_shape
|
Retained measure batch.
TYPE:
|
active
|
Boolean batch selection.
TYPE:
|
event_shape
|
Intrinsic event coordinates.
TYPE:
|
output_shape
|
Optional selected batch layout.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
InverseBijector
|
Inverse transformation on the selected batch. |
Source code in src/quivers/continuous/bijectors.py
ComposeBijector
¶
Bases: Bijector
Composition outer ∘ inner. Forward applies inner first
then outer; inverse applies outer.inverse first then
inner.inverse. Log-Jacobians add by the chain rule.
Source code in src/quivers/continuous/bijectors.py
forward_shape
¶
inverse_shape
¶
select_batch
¶
Select both retained transformations under the same batch layout.
| PARAMETER | DESCRIPTION |
|---|---|
batch_shape
|
Retained measure batch.
TYPE:
|
active
|
Boolean batch selection.
TYPE:
|
event_shape
|
Intrinsic event coordinates.
TYPE:
|
output_shape
|
Optional selected batch layout.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ComposeBijector
|
Composition of the selected transformations. |
Source code in src/quivers/continuous/bijectors.py
IdentityBijector
¶
Bases: Bijector
The identity map. Useful as a neutral element in compositions and as the trivial pushforward.
ExpBijector
¶
Bases: Bijector
The exponential map \(f(x) = e^x\) from \(\mathbb{R}\) to \((0, \infty)\). Jacobian log-determinant is \(x\).
LogBijector
¶
Bases: Bijector
The logarithm \(f(x) = \log x\) from \((0, \infty)\) to
\(\mathbb{R}\). Inverse of ExpBijector;
Jacobian log-determinant is \(-\log x\).
SigmoidBijector
¶
Bases: Bijector
The logistic sigmoid \(f(x) = 1/(1 + e^{-x})\) from \(\mathbb{R}\) to \((0, 1)\).
The Jacobian log-determinant is the log-density of the standard logistic distribution, \(-x - 2\log(1 + e^{-x})\), in a form that is stable in both tails.
LogitBijector
¶
Bases: Bijector
The logit \(f(x) = \log(x / (1 - x))\) from \((0, 1)\) to
\(\mathbb{R}\). Inverse of SigmoidBijector.
SoftplusBijector
¶
Bases: Bijector
The softplus map \(f(x) = \log(1 + e^x)\) from \(\mathbb{R}\)
to \((0, \infty)\). Smooth alternative to
ExpBijector with linear tail growth
on the positive side.
Forward Jacobian: \(df/dx = \sigma(x)\), so \(\log|df/dx| = -\text{softplus}(-x)\).
Inverse: \(f^{-1}(y) = \log(e^y - 1)\). Inverse Jacobian: \(df^{-1}/dy = 1/(1 - e^{-y})\), so \(\log|df^{-1}/dy| = -\log(1 - e^{-y}) = -\log(-\mathrm{expm1}(-y))\).
AffineBijector
¶
Bases: Bijector
The affine map \(f(x) = \text{scale} \cdot x + \text{shift}\).
scale must be strictly positive; the Jacobian log-determinant
is \(\log\,\text{scale}\), broadcast to the input shape.
Source code in src/quivers/continuous/bijectors.py
StickBreakingBijector
¶
Bases: Bijector
The stick-breaking map from \(\mathbb{R}^{K-1}\) to the open \(K\)-simplex \(\{p \in \mathbb{R}^K_{>0} : \sum_k p_k = 1\}\).
Forward: \(y_k = z_k \cdot \prod_{j<k}(1 - z_j)\) for \(k < K-1\), where \(z_k = \sigma(x_k - \log(K - k - 1))\), and \(y_{K-1} = 1 - \sum_{k<K-1} y_k\). The shift by \(\log(K - k - 1)\) centres the prior on the uniform simplex when \(x \sim \mathrm{Normal}(0, 1)\), matching the convention used by Stan and PyMC.
Inverse: \(x_k = \sigma^{-1}(z_k) + \log(K - k - 1)\) where \(z_k = y_k / (1 - \sum_{j<k} y_j)\).
The Jacobian log-determinant in the forward direction sums
log(z_k) + log(1 - z_k) + log(remaining) across the K-1
stick-breaks. Used in the desugaring of LogisticNormal and
other simplex-valued transforms.
forward_shape
¶
Add the final simplex coordinate to a vector event.
| PARAMETER | DESCRIPTION |
|---|---|
shape
|
Real-coordinate vector event shape.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Size
|
Simplex event shape with one additional coordinate. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the input has no intrinsic vector axis. |
Source code in src/quivers/continuous/bijectors.py
inverse_shape
¶
Remove the simplex's redundant coordinate from its event shape.
| PARAMETER | DESCRIPTION |
|---|---|
shape
|
Simplex event shape.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Size
|
Real-coordinate event shape. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no nonempty simplex coordinate axis is supplied. |
Source code in src/quivers/continuous/bijectors.py
Cited sources¶
Danilo Rezende and Shakir Mohamed. Variational Inference with Normalizing Flows. In Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, 1530–1538. 2015. URL: https://proceedings.mlr.press/v37/rezende15.html.
Stan Development Team. Reparameterization and change of variables. Stan User's Guide, version 2.40, n.d.-f. URL: https://mc-stan.org/docs/stan-users-guide/reparameterization.html (visited on 2026-11-06).