Issue with sweeping variables in nested dictionary in config
See original GitHub issueSomething seems wrong with nested parameters. The docs states, that dot is used to define nested variables in config.
This means that defining the following default config:
config = dict(
my_dict = dict(inner_a = 'inner_a')
)
It should be possible to set inner_a to 'inner_a_from_sweep by the sweep:
method: random
metric:
goal: minimize
name: ""
parameters:
my_dict.inner_a:
distribution: categorical
values:
- inner_a_from_sweep
program: train.py
But running this:
config = dict(
a = 'variable_a',
my_dict = dict(inner_a = 'inner_a')
)
wandb.init(config=config)
config = wandb.config
print(config)
Outputs:
wandb_version: 1
_wandb:
desc: null
value:
cli_version: 0.8.32
code_path: code/../.local/bin/wandb
is_jupyter_run: false
is_kaggle_kernel: false
python_version: 3.6.9
my_dict:
desc: null
value:
inner_a: inner_a
my_dict.inner_a:
desc: null
value: inner_a_from_sweep
It seems like there is an issue with converting dot-variables back to dictionaries. I have fixed this myself by (though it is not very pretty and only works on one depth):
def fix_dict_in_config(wandb):
config = dict(wandb.config)
for k, v in config.copy().items():
if '.' in k:
new_key = k.split('.')[0]
inner_key = k.split('.')[1]
if new_key not in config.keys():
config[new_key] = {}
config[new_key].update({inner_key: v})
del config[k]
wandb.config = Config()
for k, v in config.items():
wandb.config[k] = v
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:20 (8 by maintainers)
Top Results From Across the Web
Issue with sweeping variables in nested dictionary in config
Something seems wrong with nested parameters. The docs states, that dot is used to define nested variables in config. ... It seems like...
Read more >python - KeyError when attempting to create a nested dictionary
The instance variable search_criteria is a dictionary. The key is a group name and the values are a list of keywords to look...
Read more >Modifying nested dictionaries in Python
My task was to take a configuration specified as a dictionary and run some function with it (the actual function is not relevant...
Read more >Robot Framework User Guide
Starting from Robot Framework 4.0, dictionary expansion can be used in combination with dictionary item access making usages like &{nested}[key] possible.
Read more >Dictionary — Godot Engine (stable) documentation in English
However, you'll have to use the bracket syntax if the key you're accessing the dictionary with isn't a fixed string (such as a...
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 FreeTop 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
Top GitHub Comments
Hi all, thank you all for the feature request! Our engineering team has implemented the ability to sweep over values that are in nested configs and this will be available in release 0.12.17 when it is available.
Thank you, Nate
@nate-wandb @sydholl the PR has been closed w/o merging - the functionality is still not there in 0.12.17 - or even RCs of 0.13.
Would you happen to have an ETA for a solution?