You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Naive application of tree_map here will throw prefix errors -- I want to override the behavior such that tree_map with d1 specified as the structure will filter out "q" above, resulting in:
Critically, I think this means that the problem must depend on structure, and not just things like the length of the flattened Pytree leave array.
One other comment:
I think it's okay if the resulting Pytree has the same structure as the base Pytree that I am filtering.
This simplifies the problem to just being able to take aPytree and attempt to inflate it to a target Pytree shape. If the filter Pytree is not a prefix of the target Pytree, the resulting Pytree after filtering will be the same shape as the target Pytree, with all None. Otherwise, it will have entries for all prefixes that come from the filter Pytree.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all!
I'm attempting to solve a
Pytree
filtering problem -- where I want to use one tree as a mask for another tree.I want to support functionality where a user can partially specify the first tree (including a tree which is non-prefix!) -- for example:
Naive application of
tree_map
here will throw prefix errors -- I want to override the behavior such thattree_map
withd1
specified as the structure will filter out"q"
above, resulting in:To complicate this problem even more, I want this to work on nested structures...
Critically, I think this means that the problem must depend on structure, and not just things like the length of the flattened
Pytree
leave array.One other comment:
I think it's okay if the resulting
Pytree
has the same structure as the basePytree
that I am filtering.This simplifies the problem to just being able to take a
Pytree
and attempt to inflate it to a targetPytree
shape. If the filterPytree
is not a prefix of the targetPytree
, the resultingPytree
after filtering will be the same shape as the targetPytree
, with allNone
. Otherwise, it will have entries for all prefixes that come from the filterPytree
.Beta Was this translation helpful? Give feedback.
All reactions