[Tune] Bug fix - HEBOSearch - accept iterables as a config search space (#24678)

HEBOSearch algorithm currently fails if the config search space contains a categorical parameter where each category is an iterable.

For instance, choosing the hidden layers of a NN:
` hyperparam_search_space = {'hidden_sizes': tune.choice([[512, 256, 128], [1024, 512, 256]])}`

This is due to the creation of the Pandas DataFrame with HEBO suggested parameters, without explicitly telling Pandas that the hyper-parameter suggestion is a single row of data while the index is being defined as a single row. This results in an exception such as "ValueError: Length of values (3) does not match length of index (1)".

Co-authored-by: Makan Arastuie <makan.arastuie@seagate.com>
This commit is contained in:
Makan Arastuie 2022-05-11 11:29:50 -06:00 committed by GitHub
parent e95207a298
commit 5e23d9e298
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -272,7 +272,7 @@ class HEBOSearch(Searcher):
if self._initial_points:
params = self._initial_points.pop(0)
suggestion = pd.DataFrame(params, index=[0])
suggestion = pd.DataFrame([params], index=[0])
else:
if (
self._batch_filled
@ -283,7 +283,7 @@ class HEBOSearch(Searcher):
suggestion = self._opt.suggest(n_suggestions=self._max_concurrent)
self._suggestions_cache = suggestion.to_dict("records")
params = self._suggestions_cache.pop(0)
suggestion = pd.DataFrame(params, index=[0])
suggestion = pd.DataFrame([params], index=[0])
self._live_trial_mapping[trial_id] = suggestion
if len(self._live_trial_mapping) >= self._max_concurrent:
self._batch_filled = True