Skip to content

Add Split bijector#82

Open
gvcallen wants to merge 1 commit into
lockwo:mainfrom
gvcallen:split
Open

Add Split bijector#82
gvcallen wants to merge 1 commit into
lockwo:mainfrom
gvcallen:split

Conversation

@gvcallen

@gvcallen gvcallen commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Adds the Split bijector similar to tpb.Split.

Together with a "Restructure" bijector, this can be used to model the probability distribution of arbitrarily complex PyTree's using simple flat based distributions.

Also updates the type hint of AbstractBijector's "inverse_and_log_det typehint" to accept a PyTree and not an Array.

Split partitions a PyTree input into several sections along a given
axis, analogous to TensorFlow Probability's Split. Also widens
AbstractBijector.inverse_and_log_det's type hint from Array to PyTree,
matching forward_and_log_det, since bijectors can now operate over
arbitrary pytree structures.

def forward_and_log_det(self, x: Array) -> tuple[tuple[Array, ...], Array]:
"""Computes y = tuple(split(x)) and log|det J(f)(x)| = 0."""
y = tuple(jnp.split(x, self.indices_or_sections, axis=self.axis))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think transformed has to be updated first since it does not support Split outputs. Split.forward() returns a tuple of arrays, but Transformed._infer_shapes_and_dtype() assumes jax.eval_shape(...) returns one array-like object with .shape and .dtype

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, is this not updated in my latest PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants