ConfigSpace icon indicating copy to clipboard operation
ConfigSpace copied to clipboard

Add Callable support for CategoricalHyperparameter

Open ThibzR opened this issue 5 years ago • 3 comments

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!

ThibzR avatar Apr 30 '20 17:04 ThibzR

I'm not maintaining this project, but my two cents: how will this behave on save-and-reload in e.g. json?

shukon avatar May 09 '20 18:05 shukon

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.

mfeurer avatar May 25 '20 08:05 mfeurer

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.

ThibzR avatar Jun 01 '20 10:06 ThibzR

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!

eddiebergman avatar Apr 16 '24 19:04 eddiebergman