Chain
- class pmrf.stats.bijectors.Chain(bijectors: Sequence[AbstractBijector])
Bases:
AbstractFwdLogDetJacBijector,AbstractInvLogDetJacBijectorComposition of a sequence of bijectors into a single bijector.
Bijectors are composable: if f and g are bijectors, then g o f is also a bijector. Given a sequence of bijectors [f1, …, fN], this class implements the bijector defined by fN o … o f1.
!!! warning “Bijectors are applied in reverse order”
Given a sequence [f, g], the Chain bijector computes f(g(x)), not g(f(x)). This matches the mathematical convention for function composition but may be counterintuitive when building layers sequentially.
!!! example
`python layers = [] layers.append(f) layers.append(g) bijector = distreqx.Chain(layers) y = bijector.forward(x) # y = f(g(x)) `Initializes a Chain bijector.
Arguments:
- bijectors: a sequence of bijectors to be composed into one. Each bijector
can be a distreqx bijector or a callable to be wrapped by Lambda. The sequence must contain at least one bijector.
- forward(x: Array) Array
Computes y = f(x).
- forward_and_log_det(x: Array) tuple[Array, Array]
Computes y = f(x) and log|det J(f)(x)|.
- inverse(y: Array) Array
Computes x = f^{-1}(y).
- inverse_and_log_det(y: Array) tuple[Array, Array]
Computes x = f^{-1}(y) and log|det J(f^{-1})(y)|.
- same_as(other: AbstractBijector) bool
Returns True if this bijector is guaranteed to be the same as other.
- bijectors: list[AbstractBijector]