test-tube icon indicating copy to clipboard operation
test-tube copied to clipboard

HyperOptArgumentParser explicit argument behaviour

Open ilsenatorov opened this issue 3 years ago • 1 comments

When I first started using the package (great work btw, thanks a lot!) I assumed that the intended behaviour for HyperOptArgumentParser is to only only iterate over the hyperparams if they are not specified in the cli.

In my opinion this would be the convenient designated behaviour and if people agree I could implement it (currently I'm using a hacky work-around.

So currently if I run python hyperparam.py --arg1 128 and the arg1 is specified as

parser.opt_list(--arg1, options=[128, 256, 512])

It would still iterate over the arg1 options. My desired behaviour would be to only iterate over the options if the argument is not explicitly given.

Currently I use this hack:

class MyArgParser(HyperOptArgumentParser):
    def my_opt_list(self, name, default, dtype, options, **kwargs):
        tunable = (name not in sys.argv)
        self.opt_list(name, default=default, type=dtype, tunable=tunable,
                      options=options,**kwargs)

Which I would be happy to implement if I'm not the only one facing this issue.

ilsenatorov avatar Jan 14 '21 10:01 ilsenatorov

I stumbled upon this issue while trying to figure out a way to tune only a list of chosen hyperparams but actually the behavior you described is way more intuitive, straightforward and convenient to use. On Monday I will first copy your current solution to my code, thank you for sharing it. If you were still motivated to do so I absolutely support implementing this as the default behavior.

MoRoBe-Work avatar Aug 20 '21 14:08 MoRoBe-Work