bijx.Inverse¶
- class bijx.Inverse[source]¶
Bases:
Bijection
Inverted bijection that swaps forward and reverse directions.
This bijection wraps another bijection and swaps its forward() and reverse() methods.
- Parameters:
bijection (
Bijection
) – The bijection to invert.
Note
Inverses of bijections should usually be created using
bij.invert()
. Then,bijx.invert().invert() == bij
. Otherwise,Inverse(Inverse(bij))
while acting the same asbij
does not “undo” the unnecessary wrapping.Methods
forward
(x, log_density, **kwargs)Apply forward transformation.
invert
()Return the original bijection (double inversion).
reverse
(x, log_density, **kwargs)Apply reverse (inverse) transformation.
- forward(x, log_density, **kwargs)[source]¶
Apply forward transformation.
Transforms input through the bijection and updates log-density according to the change of variables formula.
For convenience
Bijection()
gives the default identity bijection.- Parameters:
x – Input data of any pytree structure.
log_density – Log density values corresponding to the input.
**kwargs – Additional transformation-specific arguments.
- Returns:
Tuple of (transformed_data, updated_log_density) where the log-density incorporates the log absolute determinant of the transformation Jacobian.
- reverse(x, log_density, **kwargs)[source]¶
Apply reverse (inverse) transformation.
Transforms input through the inverse bijection and updates log-density accordingly.
- Parameters:
x – Input data of any pytree structure.
log_density – Log density values corresponding to the input.
**kwargs – Additional transformation-specific arguments.
- Returns:
Tuple of (inverse_transformed_data, updated_log_density) where the log-density change has the opposite sign compared to forward().