Add support for hierarchical dict
See original GitHub issue🚀 Feature
Motivation
Since v0.7.0, LightningModule accepts dict hparams, however, still TensorBoardLogger raises an error with hierarchical dict. Considering the compatibility of the other package, especially Hydra #807, hierarchical dict should be accepted by any loggers.
Pitch
- Flatten hierarchical dict before hparam logging
Alternatives
The function _convert_params
in loggers/base.py will be changed like:
def _convert_params(self, params: Union[Dict[str, Any], Namespace]) -> Dict[str, Any]:
# in case converting from namespace
if isinstance(params, Namespace):
params = vars(params)
# added part
params = flatten_dict(params) # convert {'a': {'b': 'c'}} -> {'a/b': 'c'}
if params is None:
params = {}
return params
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Add support for hierarchical dict · Issue #1144 · Lightning-AI ...
Since v0.7.0, LightningModule accepts dict hparams, however, still TensorBoardLogger raises an error with hierarchical dict. Considering the ...
Read more >Build nested/hierarchical dictionary from irregular flat dictionary
We split to lists of address items. We then pass an output dictionary into make recursive entry. In this function, if the address...
Read more >Python Nested Dictionary (With Examples) - Programiz
In this article, you'll learn about nested dictionary in Python. ... create nested dictionary, access elements, modify them and so on with the...
Read more >Python: Update Nested Dictionary - GeeksforGeeks
This method unflattens the flattened dictionary and converts it into a nested one. It can take three arguments : dict : The flattened...
Read more >Multiple nested dictionaries following hierarchy - CodeProject
I've been struggling for a while trying to figure it out to put some hierarchical values in a flat table into a specific...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could we implement this in such as way to enable the use of
writer.add_scalars()
for the Tensorboard version? When you use this method it plots the values on a single chart (versus grouping charts with individual metrics when you organize tags likeparent/child
).eg.
versus
Could you pls comment on these PRs thow…
Could you open an issue and raise/start such discussion (or jsut continue in the Hydra one?)