-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to simplify
keystr
output and use a custom separator.
Currently `keystr` just calls `str` on the key entries, leading to quite verbose output. For example: >>> params = {'foo': {'bar': {'baz': 1, 'bat': [2, 3]}}} ... for path, _ in jax.tree_util.tree_leaves_with_path(params): ... print(jax.tree_util.keystr(path)) ['foo']['bar']['bat'][0] ['foo']['bar']['bat'][1] ['foo']['bar']['baz'] This change allows for a new "simple" format where the string representation of key entries are further simplified. Additionally we allow a custom separator since it is very common to use `/` (for example to separate module and parameter names): ... for path, _ in jax.tree_util.tree_leaves_with_path(params): ... print(jax.tree_util.keystr(path, simple=True, separator='/')) foo/bar/bat/0 foo/bar/bat/1 foo/bar/baz ``` PiperOrigin-RevId: 717971583
- Loading branch information
1 parent
96a3ed3
commit 7f43316
Showing
2 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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