gensbi.normalizing_flows.bijections.base#
Bijection abstract base and the non-trainable Mask variable type.
Classes#
Module Contents#
- class gensbi.normalizing_flows.bijections.base.Bijection[source]#
Bases:
flax.nnx.ModuleInvertible map between a noise variable and a data variable.
Subclasses implement a differentiable bijection with a direction convention fixed across the library:
forward()maps noise to data (the sampling direction) andinverse()maps data to noise (the density-evaluation direction). Both directions also return the log absolute determinant of the Jacobian of the transform they apply.- abstractmethod forward(u, cond=None)[source]#
Map noise to data (the sampling direction).
- Parameters:
u (Array) – Noise-space input.
cond (Array or None, optional) – Conditioning input, or
Nonefor an unconditional map.
- Returns:
x (Array) – Data-space output.
logabsdet (Array) – Log absolute determinant of the Jacobian of the forward map.
- Raises:
NotImplementedError – This is an abstract method; subclasses must override it.
- Return type:
tuple[jax.Array, jax.Array]
- abstractmethod inverse(x, cond=None)[source]#
Map data to noise (the density-evaluation direction).
- Parameters:
x (Array) – Data-space input.
cond (Array or None, optional) – Conditioning input, or
Nonefor an unconditional map.
- Returns:
u (Array) – Noise-space output.
logabsdet (Array) – Log absolute determinant of the Jacobian of the inverse map.
- Raises:
NotImplementedError – This is an abstract method; subclasses must override it.
- Return type:
tuple[jax.Array, jax.Array]
- class gensbi.normalizing_flows.bijections.base.Mask(value, *, hijax=None, ref=None, eager_sharding=None, **metadata)[source]#
Bases:
flax.nnx.VariableFixed (non-trainable) buffer for bijection metadata.
A non-
ParamVariablesubclass so that optimizers and EMA utilities skip it while checkpointing still saves and restores it. Typical use: autoregressive masks inMaskedAutoregressive.- Parameters:
value (A | VariableMetadata[A])
hijax (bool | None)
ref (bool | None)
eager_sharding (bool | None)
metadata (Any)