Add Restructure#81
Open
gvcallen wants to merge 2 commits into
Open
Conversation
Owner
|
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. |
Contributor
Author
|
@lockwo ah I see, yes I'm personally dealing with very nested Pytrees all the time :D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Restructurebijector, 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.Restructurecan then be used (along withSplit) 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 aJointdistribution and potentially a multi-bijector similar to tbf'sJointMap, and I think its then possible to model arbitrary correlations across arbitrary pytree structures and leaves.