question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
jeremyjordancommented, Mar 14, 2020

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 like parent/child).

eg. add_scalars

versus

parent/child

1reaction
Bordacommented, Mar 14, 2020

I saw the PRs #1130 #1128, then I feel there are some conflicts between the PRs. For example, if non-primitive types are converted to str by #1130, #1128 does not have any effects.

Could you pls comment on these PRs thow…

The integrative discussion around hparams is needed I think.

Could you open an issue and raise/start such discussion (or jsut continue in the Hydra one?)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found