gin-config icon indicating copy to clipboard operation
gin-config copied to clipboard

Instead of files, programmatically create gin config

Open bayerj opened this issue 5 years ago • 2 comments

In my use cases, I rarely set hyper parameters by hand. Instead I have an external logic that generates them (e.g. random search). Now, using gin it seems I would have to create config files programmatically, e.g. through templates.

That feels "wrong", even though I could go that route: have a process that creates config files from templates (which would be programmatically generated by inspecting the respective module using gin), then start the processes in a second go.

Nevertheless, I was wondering if I am missing an obvious path to get the same out of it. Soemthing like setting the configuration through pure python, instead of going through gin's own format, would do the job.

bayerj avatar May 17 '19 17:05 bayerj

Currently, you can assign values to parameters in code using gin.bind_parameter

value = ...
gin.bind_parameter('my_function.parameter', value)

We are thinking in being able to create configurations as Python objects, but not ETA at the moment.

sguada avatar May 20 '19 18:05 sguada

@bayerj @sguada bump, I'd love to use gin to configure Optuna or Keras-Tuner searches; i have a bunch of bricks each with parameters pulled to the top of the file (MIN_STACKS = 2 ) for example ... i guess i could make these into kwargs, configure those with gin, then add an AI.pull method to the Agent class which asks Optuna for a parameter value given a range. Then instead of hunting through 50 little files for config, i can configure search spaces in one big file (hopefully not TOO big)

one issue is, some of the config stuff ought to really be itself pulled from the search, as justin rightly points out. might be possible to make the main file for a program generate a gin config just by writing lines.

For example, Dense blocks concat their outputs, which impacts the size of the code, which would be good to put in other parts of the config ... D_CODE = 3 + DenseBlock.layers * DenseBlock.units

bionicles avatar Sep 28 '19 02:09 bionicles