Skip to content

Add Inverse and Identity#64

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

Add Inverse and Identity#64
gvcallen wants to merge 1 commit into
lockwo:mainfrom
gvcallen:identity_and_inverse

Conversation

@gvcallen

@gvcallen gvcallen commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Implements the simple utility Inverse and Identity bijectors.

@gvcallen gvcallen changed the title Implement Inverse and Identity Add Inverse and Identity Apr 4, 2026
@gvcallen gvcallen changed the title Add Inverse and Identity Add Inverse and Identity bijectors Apr 4, 2026
@gvcallen gvcallen changed the title Add Inverse and Identity bijectors Add Inverse and Identity Apr 4, 2026
Comment thread distreqx/bijectors/_identity.py Outdated

def forward_and_log_det(self, x: PyTree) -> tuple[PyTree, PyTree]:
"""Computes y = x and log|det J(f)(x)| = 0."""
log_det = jax.tree_util.tree_map(jnp.zeros_like, x)

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.

Can just be jax.tree.map?

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.

Oh yes, would you like me to commit changes like these?

Comment thread tests/inverse_test.py

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.

should be tested with more complicated bijector than just identity

gvcallen added a commit to gvcallen/distreqx that referenced this pull request Jul 1, 2026
- Simplify Identity's forward/inverse log-det computation to jax.tree.map
  per lockwo's suggestion.
- Test Inverse with a non-trivial bijector (ScalarAffine), not just Identity.
Identity is a no-op bijector (y = x). Inverse wraps another bijector,
swapping its forward/inverse and forward/inverse log-det Jacobian
directions, validating that the wrapped bijector's constant-jacobian
flags are internally consistent.
@gvcallen gvcallen force-pushed the identity_and_inverse branch from 84f3f05 to aa623e7 Compare July 1, 2026 20:59
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