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
We can use the gin.operative_config_str(), which prints a useful overview. However, for logging the saved parameters, some people (me included) like to query the internal dictionary. We can access it with gin.config._OPERATIVE_CONFIG (recommended) or gin.config._CONFIG (not recommended, also includes unused parameters). However, this requires additional parsing.
For this, I came up with the following code:
def gin_config_to_readable_dictionary(gin_config: dict):
"""
Parses the gin configuration to a dictionary. Useful for logging to e.g. W&B
:param gin_config: the gin's config dictionary. Can be obtained by gin.config._OPERATIVE_CONFIG
:return: the parsed (mainly: cleaned) dictionary
"""
data = {}
for key in gin_config.keys():
name = key[1].split(".")[1]
values = gin_config[key]
for k, v in values.items():
data[".".join([name, k])] = v
return data
Thanks, I was looking for exactly this, and I believe that this should be part of gin.utils or something. Especially for keeping track of different experiment runs, it's much more useful to have a dict as opposed to a pre-generated string with newlines.
We can use the
gin.operative_config_str()
, which prints a useful overview. However, for logging the saved parameters, some people (me included) like to query the internal dictionary. We can access it withgin.config._OPERATIVE_CONFIG
(recommended) orgin.config._CONFIG
(not recommended, also includes unused parameters). However, this requires additional parsing.For this, I came up with the following code:
An example output is given below:
The naming follows the way parameter values are stored in a
config.gin
file: the decorated class/function name, followed by the parameter's name.This is not a critical thing, but it might be useful as an enhancement.
The text was updated successfully, but these errors were encountered: