Add Callable support for CategoricalHyperparameter
fix #133
One can now directly pass a Callable when creating a CategoricalHyperparameter. This is streamlining prototyping. Couple of examples:
CategoricalHyperparameter('final_activation', [nn.Softmax(dim=1), nn.Sigmoid()])CategoricalHyperparameter('loss_function', [nn.L1Loss, nn.MSELoss])
Previously, one needed to provide strings, check value later and create the object accordingly.
I've checked my changes on a heavy hyperparameter optimization project of mine and works like a charm. Let me know if any comment!
I'm not maintaining this project, but my two cents: how will this behave on save-and-reload in e.g. json?
I'm not maintaining this project, but my two cents: how will this behave on save-and-reload in e.g. json?
It would basically make it impossible to save/load configuration spaces expect for using pickle.
I hope that I can have a look at this PR soonish.
I'm not maintaining this project, but my two cents: how will this behave on save-and-reload in e.g. json?
It would basically make it impossible to save/load configuration spaces expect for using pickle.
Indeed, pickle handles that nicely. I'd say the feature comes with a tradeoff, but no breaking change as to the existing package.
Sorry, this was a nice suggestoin and thanks for the PR! It's been superseded by #359 and allows arbitrary objects, including functions, in the categorical or ordinal :) Will close and leave the original issue open until that PR is merged!