Skip to content

Add Restructure#81

Open
gvcallen wants to merge 2 commits into
lockwo:mainfrom
gvcallen:restructure
Open

Add Restructure#81
gvcallen wants to merge 2 commits into
lockwo:mainfrom
gvcallen:restructure

Conversation

@gvcallen
Copy link
Copy Markdown
Contributor

@gvcallen gvcallen commented Apr 30, 2026

Adds the Restructure bijector similar to tfb.Restructure.

@lockwo I'm not sure how you feel about adding these types of bijectors into distreqx, however I feel they are very necessary if the end goal is a self-contained package with no interop with Tensorflow. Although I'm not sure which direction you are intending for the library to go, I feel there's a definite need in the Equinox ecosystem for a native distribution + bijector library, which these kinds of classes are necessary for.

As an example "critical" use case for this Restructure bijector, I have found it is essentially impossible to easily model correlations between arbitrary pytree leaves without it, without maintaining lots of boilerplate. In my specific case, I am training a normalizing flow on samples of specific leaves in my tree. Restructure can then be used (along with Split) to restructure the flow's output so that it properly represents a distribution over my specific tree, as opposed to only a sub-portion of my tree's leaves flattened which then I must map manually. Combined with a Joint distribution and potentially a multi-bijector similar to tbf's JointMap, and I think its then possible to model arbitrary correlations across arbitrary pytree structures and leaves.

@lockwo
Copy link
Copy Markdown
Owner

lockwo commented May 6, 2026

Yea I think these are in general ok add. Although distrax doesn't have them, I think distrax was very array focused. I think most users (including myself) generally work with arrays, and this pytree stuff is strictly additive so users concerned with only arrays are ok either way.

@gvcallen
Copy link
Copy Markdown
Contributor Author

gvcallen commented May 7, 2026

@lockwo ah I see, yes I'm personally dealing with very nested Pytrees all the time :D

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