From a67aefe62e8dc25e8b27f80ad48bdaec14160d1a Mon Sep 17 00:00:00 2001 From: avelichk Date: Mon, 17 Feb 2020 17:46:18 +0000 Subject: [PATCH 01/10] Add first run condition in BO Suggestion --- .../v1alpha3/skopt/base_skopt_service.py | 48 ++++++++++--------- pkg/suggestion/v1alpha3/skopt_service.py | 48 +++++++++++-------- 2 files changed, 54 insertions(+), 42 deletions(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index 64da07146e1..2d34a851492 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -14,27 +14,26 @@ class BaseSkoptService(object): Refer to https://github.com/scikit-optimize/scikit-optimize . """ - def __init__(self, algorithm_name="skopt-bayesian-optimization", + def __init__(self, base_estimator="GP", n_initial_points=10, acq_func="gp_hedge", acq_optimizer="auto", - random_state=None): + random_state=None, + search_space=None): self.base_estimator = base_estimator self.n_initial_points = n_initial_points self.acq_func = acq_func self.acq_optimizer = acq_optimizer self.random_state = random_state - self.algorithm_name = algorithm_name - - def getSuggestions(self, search_space, trials, request_number): - """ - Get the new suggested trials with skopt algorithm. - """ + self.search_space = search_space + self.skopt_optimizer = None + self.create_optimizer() + def create_optimizer(self): skopt_search_space = [] - for param in search_space.params: + for param in self.search_space.params: if param.type == INTEGER: skopt_search_space.append(skopt.space.Integer( int(param.min), int(param.max), name=param.name)) @@ -45,21 +44,24 @@ def getSuggestions(self, search_space, trials, request_number): skopt_search_space.append( skopt.space.Categorical(param.list, name=param.name)) - if self.algorithm_name != "bayesianoptimization": - raise Exception( - '"Failed to create the algortihm: {}'.format(self.algorithm_name)) - skopt_optimizer = skopt.Optimizer(skopt_search_space, - base_estimator=self.base_estimator, - n_initial_points=self.n_initial_points, - acq_func=self.acq_func, - acq_optimizer=self.acq_optimizer, - random_state=self.random_state) + self.skopt_optimizer = skopt.Optimizer( + skopt_search_space, + base_estimator=self.base_estimator, + n_initial_points=self.n_initial_points, + acq_func=self.acq_func, + acq_optimizer=self.acq_optimizer, + random_state=self.random_state) + + def getSuggestions(self, trials, request_number): + """ + Get the new suggested trials with skopt algorithm. + """ skopt_suggested = [] loss_for_skopt = [] for trial in trials: trial_assignment = [] - for param in search_space.params: + for param in self.search_space.params: parameter_value = None for assignment in trial.assignments: if assignment.name == param.name: @@ -74,19 +76,19 @@ def getSuggestions(self, search_space, trials, request_number): skopt_suggested.append(trial_assignment) loss_value = float(trial.target_metric.value) - if search_space.goal == MAX_GOAL: + if self.search_space.goal == MAX_GOAL: loss_value = -1 * loss_value loss_for_skopt.append(loss_value) if loss_for_skopt != [] and skopt_suggested != []: - skopt_optimizer.tell(skopt_suggested, loss_for_skopt) + self.skopt_optimizer.tell(skopt_suggested, loss_for_skopt) return_trial_list = [] for i in range(request_number): - skopt_suggested = skopt_optimizer.ask() + skopt_suggested = self.skopt_optimizer.ask() return_trial_list.append( - BaseSkoptService.convert(search_space, skopt_suggested)) + BaseSkoptService.convert(self.search_space, skopt_suggested)) return return_trial_list @staticmethod diff --git a/pkg/suggestion/v1alpha3/skopt_service.py b/pkg/suggestion/v1alpha3/skopt_service.py index 2fcbbb4f289..f7dc96950ca 100644 --- a/pkg/suggestion/v1alpha3/skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt_service.py @@ -11,25 +11,35 @@ logger = logging.getLogger("SkoptService") -class SkoptService( - api_pb2_grpc.SuggestionServicer, HealthServicer): +class SkoptService(api_pb2_grpc.SuggestionServicer, HealthServicer): + + def __init__(self): + super(SkoptService, self).__init__() + self.base_service = None + self.is_first_run = True + def GetSuggestions(self, request, context): """ Main function to provide suggestion. """ - name, config = OptimizerConfiguration.convertAlgorithmSpec( + algorithm_name, config = OptimizerConfiguration.convertAlgorithmSpec( request.experiment.spec.algorithm) - base_service = BaseSkoptService( - algorithm_name=name, - base_estimator=config.base_estimator, - n_initial_points=config.n_initial_points, - acq_func=config.acq_func, - acq_optimizer=config.acq_optimizer, - random_state=config.random_state) + if algorithm_name != "bayesianoptimization": + raise Exception("Failed to create the algortihm: {}".format(algorithm_name)) + search_space = HyperParameterSearchSpace.convert(request.experiment) + if self.is_first_run: + self.base_service = BaseSkoptService( + base_estimator=config.base_estimator, + n_initial_points=config.n_initial_points, + acq_func=config.acq_func, + acq_optimizer=config.acq_optimizer, + random_state=config.random_state, + search_space=search_space) + self.is_first_run = False + trials = Trial.convert(request.trials) - new_trials = base_service.getSuggestions( - search_space, trials, request.request_number) + new_trials = self.base_service.getSuggestions(trials, request.request_number) return api_pb2.GetSuggestionsReply( parameter_assignments=Assignment.generate(new_trials) ) @@ -49,16 +59,16 @@ def __init__(self, base_estimator="GP", @staticmethod def convertAlgorithmSpec(algorithm_spec): - optmizer = OptimizerConfiguration() + optimizer = OptimizerConfiguration() for s in algorithm_spec.algorithm_setting: if s.name == "base_estimator": - optmizer.base_estimator = s.value + optimizer.base_estimator = s.value elif s.name == "n_initial_points": - optmizer.n_initial_points = int(s.value) + optimizer.n_initial_points = int(s.value) elif s.name == "acq_func": - optmizer.acq_func = s.value + optimizer.acq_func = s.value elif s.name == "acq_optimizer": - optmizer.acq_optimizer = s.value + optimizer.acq_optimizer = s.value elif s.name == "random_state": - optmizer.random_state = int(s.value) - return algorithm_spec.algorithm_name, optmizer + optimizer.random_state = int(s.value) + return algorithm_spec.algorithm_name, optimizer From ccfcdf94d70e80fed9b0c6ea4a9ce72ed23f43c0 Mon Sep 17 00:00:00 2001 From: avelichk Date: Tue, 18 Feb 2020 17:13:01 +0000 Subject: [PATCH 02/10] Tell to Optimizer only about new Trials --- .../v1alpha3/skopt/base_skopt_service.py | 74 ++++++++++++------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index 2d34a851492..5b8ad0c879f 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -29,6 +29,9 @@ def __init__(self, self.search_space = search_space self.skopt_optimizer = None self.create_optimizer() + self.succeeded_trials = 0 + # Dict of recorded trials where key = loss value, value = List of trial assignment list for this value + self.recorded_trials = {} def create_optimizer(self): skopt_search_space = [] @@ -59,36 +62,48 @@ def getSuggestions(self, trials, request_number): skopt_suggested = [] loss_for_skopt = [] - for trial in trials: - trial_assignment = [] - for param in self.search_space.params: - parameter_value = None - for assignment in trial.assignments: - if assignment.name == param.name: - parameter_value = assignment.value - break - if param.type == INTEGER: - trial_assignment.append(int(parameter_value)) - elif param.type == DOUBLE: - trial_assignment.append(float(parameter_value)) - else: - trial_assignment.append(parameter_value) - skopt_suggested.append(trial_assignment) - - loss_value = float(trial.target_metric.value) - if self.search_space.goal == MAX_GOAL: - loss_value = -1 * loss_value - loss_for_skopt.append(loss_value) - - if loss_for_skopt != [] and skopt_suggested != []: - self.skopt_optimizer.tell(skopt_suggested, loss_for_skopt) - return_trial_list = [] + if len(trials) > self.succeeded_trials or self.succeeded_trials == 0: + self.succeeded_trials = len(trials) + logger.info("Succeeded Trials: {}".format(self.succeeded_trials)) + for trial in trials: + trial_assignment = [] + for param in self.search_space.params: + parameter_value = None + for assignment in trial.assignments: + if assignment.name == param.name: + parameter_value = assignment.value + break + if param.type == INTEGER: + trial_assignment.append(int(parameter_value)) + elif param.type == DOUBLE: + trial_assignment.append(float(parameter_value)) + else: + trial_assignment.append(parameter_value) + + loss_value = float(trial.target_metric.value) + if self.search_space.goal == MAX_GOAL: + loss_value = -1 * loss_value + + # Update only for new values + if loss_value not in self.recorded_trials: + self.recorded_trials[loss_value] = [] + self.recorded_trials[loss_value].append(trial_assignment) + skopt_suggested.append(trial_assignment) + loss_for_skopt.append(loss_value) + elif trial_assignment not in self.recorded_trials[loss_value]: + self.recorded_trials[loss_value].append(trial_assignment) + skopt_suggested.append(trial_assignment) + loss_for_skopt.append(loss_value) + + if loss_for_skopt != [] and skopt_suggested != []: + self.skopt_optimizer.tell(skopt_suggested, loss_for_skopt) + + for i in range(request_number): + skopt_suggested = self.skopt_optimizer.ask() + return_trial_list.append( + BaseSkoptService.convert(self.search_space, skopt_suggested)) - for i in range(request_number): - skopt_suggested = self.skopt_optimizer.ask() - return_trial_list.append( - BaseSkoptService.convert(self.search_space, skopt_suggested)) return return_trial_list @staticmethod @@ -102,4 +117,7 @@ def convert(search_space, skopt_suggested): assignments.append(Assignment(param.name, skopt_suggested[i])) elif param.type == CATEGORICAL or param.type == DISCRETE: assignments.append(Assignment(param.name, skopt_suggested[i])) + for a in assignments: + logger.info("Generate new Trial with Assignment") + logger.info(a) return assignments From 1d8354ee47ccc51fb0fa8e6bdbd8f0569582aa69 Mon Sep 17 00:00:00 2001 From: avelichk Date: Tue, 18 Feb 2020 18:14:28 +0000 Subject: [PATCH 03/10] Logging Return new trials in each getSuggestion call --- .../v1alpha3/skopt/base_skopt_service.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index 5b8ad0c879f..c8c0c52aedd 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -59,13 +59,14 @@ def getSuggestions(self, trials, request_number): """ Get the new suggested trials with skopt algorithm. """ - + logger.info("-" * 100 + "\n") + logger.info("New GetSuggestions call\n") skopt_suggested = [] loss_for_skopt = [] return_trial_list = [] if len(trials) > self.succeeded_trials or self.succeeded_trials == 0: self.succeeded_trials = len(trials) - logger.info("Succeeded Trials: {}".format(self.succeeded_trials)) + logger.info("Succeeded Trials changed: {}\n".format(self.succeeded_trials)) for trial in trials: trial_assignment = [] for param in self.search_space.params: @@ -97,12 +98,19 @@ def getSuggestions(self, trials, request_number): loss_for_skopt.append(loss_value) if loss_for_skopt != [] and skopt_suggested != []: + logger.info("Running Optimizer tell to record observation") + logger.info("Evaluated parameters: {}".format(skopt_suggested)) + logger.info("Objective values: {}\n".format(loss_for_skopt)) self.skopt_optimizer.tell(skopt_suggested, loss_for_skopt) - for i in range(request_number): - skopt_suggested = self.skopt_optimizer.ask() - return_trial_list.append( - BaseSkoptService.convert(self.search_space, skopt_suggested)) + else: + logger.info("Succeeded Trials didn't change: {}\n".format(self.succeeded_trials)) + + logger.info("Running Optimizer ask to query new parameters for {} Trials".format(request_number)) + skopt_suggested = self.skopt_optimizer.ask(n_points=request_number) + logger.info("New suggested parameters for Trials: {}\n\n".format(skopt_suggested)) + for suggested in skopt_suggested: + return_trial_list.append(BaseSkoptService.convert(self.search_space, suggested)) return return_trial_list @@ -117,7 +125,4 @@ def convert(search_space, skopt_suggested): assignments.append(Assignment(param.name, skopt_suggested[i])) elif param.type == CATEGORICAL or param.type == DISCRETE: assignments.append(Assignment(param.name, skopt_suggested[i])) - for a in assignments: - logger.info("Generate new Trial with Assignment") - logger.info(a) return assignments From 82e918d7d519301de7462dfb939b65026dd5a4b8 Mon Sep 17 00:00:00 2001 From: avelichk Date: Tue, 18 Feb 2020 18:18:26 +0000 Subject: [PATCH 04/10] Small fix log --- pkg/suggestion/v1alpha3/skopt/base_skopt_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index c8c0c52aedd..6f561e4139b 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -66,7 +66,7 @@ def getSuggestions(self, trials, request_number): return_trial_list = [] if len(trials) > self.succeeded_trials or self.succeeded_trials == 0: self.succeeded_trials = len(trials) - logger.info("Succeeded Trials changed: {}\n".format(self.succeeded_trials)) + logger.info("Succeeded Trials changed or first call: {}\n".format(self.succeeded_trials)) for trial in trials: trial_assignment = [] for param in self.search_space.params: From 423be1054ae89df45f29467d11b65e2858b42565 Mon Sep 17 00:00:00 2001 From: avelichk Date: Tue, 18 Feb 2020 18:54:17 +0000 Subject: [PATCH 05/10] Remove n_points from ask --- pkg/suggestion/v1alpha3/skopt/base_skopt_service.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index 6f561e4139b..2ea868490d0 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -63,7 +63,6 @@ def getSuggestions(self, trials, request_number): logger.info("New GetSuggestions call\n") skopt_suggested = [] loss_for_skopt = [] - return_trial_list = [] if len(trials) > self.succeeded_trials or self.succeeded_trials == 0: self.succeeded_trials = len(trials) logger.info("Succeeded Trials changed or first call: {}\n".format(self.succeeded_trials)) @@ -106,12 +105,14 @@ def getSuggestions(self, trials, request_number): else: logger.info("Succeeded Trials didn't change: {}\n".format(self.succeeded_trials)) - logger.info("Running Optimizer ask to query new parameters for {} Trials".format(request_number)) - skopt_suggested = self.skopt_optimizer.ask(n_points=request_number) - logger.info("New suggested parameters for Trials: {}\n\n".format(skopt_suggested)) - for suggested in skopt_suggested: - return_trial_list.append(BaseSkoptService.convert(self.search_space, suggested)) + logger.info("Running Optimizer ask to query new parameters for {} Trials\n".format(request_number)) + return_trial_list = [] + for i in range(request_number): + skopt_suggested = self.skopt_optimizer.ask() + logger.info("New suggested parameters for Trial: {}".format(skopt_suggested)) + return_trial_list.append( + BaseSkoptService.convert(self.search_space, skopt_suggested)) return return_trial_list @staticmethod From 505567490ff82a9982dd22d3b4c21dccbda2e6c0 Mon Sep 17 00:00:00 2001 From: avelichk Date: Tue, 18 Feb 2020 18:58:18 +0000 Subject: [PATCH 06/10] Fix log --- pkg/suggestion/v1alpha3/skopt/base_skopt_service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index 2ea868490d0..35eefaf6795 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -65,7 +65,8 @@ def getSuggestions(self, trials, request_number): loss_for_skopt = [] if len(trials) > self.succeeded_trials or self.succeeded_trials == 0: self.succeeded_trials = len(trials) - logger.info("Succeeded Trials changed or first call: {}\n".format(self.succeeded_trials)) + if self.succeeded_trials != 0: + logger.info("Succeeded Trials changed: {}\n".format(self.succeeded_trials)) for trial in trials: trial_assignment = [] for param in self.search_space.params: From de6202b049cc0b4d7b7f666bdd9a05eeff965842 Mon Sep 17 00:00:00 2001 From: avelichk Date: Tue, 18 Feb 2020 19:02:16 +0000 Subject: [PATCH 07/10] Add newline to log --- pkg/suggestion/v1alpha3/skopt/base_skopt_service.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index 35eefaf6795..f108489b51a 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -107,13 +107,15 @@ def getSuggestions(self, trials, request_number): logger.info("Succeeded Trials didn't change: {}\n".format(self.succeeded_trials)) logger.info("Running Optimizer ask to query new parameters for {} Trials\n".format(request_number)) + return_trial_list = [] for i in range(request_number): - skopt_suggested = self.skopt_optimizer.ask() - logger.info("New suggested parameters for Trial: {}".format(skopt_suggested)) - return_trial_list.append( - BaseSkoptService.convert(self.search_space, skopt_suggested)) + skopt_suggested = self.skopt_optimizer.ask() + logger.info("New suggested parameters for Trial: {}".format(skopt_suggested)) + return_trial_list.append( + BaseSkoptService.convert(self.search_space, skopt_suggested)) + logger.info("\n" * 3) return return_trial_list @staticmethod From d1f857a4750a2aa47b2ff93585f22695c3c1cfe5 Mon Sep 17 00:00:00 2001 From: avelichk Date: Tue, 18 Feb 2020 19:15:15 +0000 Subject: [PATCH 08/10] Change log --- pkg/suggestion/v1alpha3/skopt/base_skopt_service.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index f108489b51a..a31322b6777 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -106,7 +106,7 @@ def getSuggestions(self, trials, request_number): else: logger.info("Succeeded Trials didn't change: {}\n".format(self.succeeded_trials)) - logger.info("Running Optimizer ask to query new parameters for {} Trials\n".format(request_number)) + logger.info("Running Optimizer ask to query new parameters for Trials\n") return_trial_list = [] @@ -115,7 +115,8 @@ def getSuggestions(self, trials, request_number): logger.info("New suggested parameters for Trial: {}".format(skopt_suggested)) return_trial_list.append( BaseSkoptService.convert(self.search_space, skopt_suggested)) - logger.info("\n" * 3) + + logger.info("GetSuggestions return {} new Trials\n\n".format(request_number)) return return_trial_list @staticmethod From 00cb7cadda9dcb3cb5188d6799eaf9c01c0dd3f8 Mon Sep 17 00:00:00 2001 From: avelichk Date: Tue, 18 Feb 2020 19:48:02 +0000 Subject: [PATCH 09/10] Change dict to list of recorded trials --- .../v1alpha3/skopt/base_skopt_service.py | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py index a31322b6777..203bce5245e 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py @@ -5,6 +5,7 @@ from pkg.suggestion.v1alpha3.internal.search_space import * from pkg.suggestion.v1alpha3.internal.trial import * +import datetime logger = logging.getLogger("BaseSkoptService") @@ -30,8 +31,8 @@ def __init__(self, self.skopt_optimizer = None self.create_optimizer() self.succeeded_trials = 0 - # Dict of recorded trials where key = loss value, value = List of trial assignment list for this value - self.recorded_trials = {} + # List of recorded Trials names + self.recorded_trials_names = [] def create_optimizer(self): skopt_search_space = [] @@ -68,40 +69,35 @@ def getSuggestions(self, trials, request_number): if self.succeeded_trials != 0: logger.info("Succeeded Trials changed: {}\n".format(self.succeeded_trials)) for trial in trials: - trial_assignment = [] - for param in self.search_space.params: - parameter_value = None - for assignment in trial.assignments: - if assignment.name == param.name: - parameter_value = assignment.value - break - if param.type == INTEGER: - trial_assignment.append(int(parameter_value)) - elif param.type == DOUBLE: - trial_assignment.append(float(parameter_value)) - else: - trial_assignment.append(parameter_value) - - loss_value = float(trial.target_metric.value) - if self.search_space.goal == MAX_GOAL: - loss_value = -1 * loss_value - - # Update only for new values - if loss_value not in self.recorded_trials: - self.recorded_trials[loss_value] = [] - self.recorded_trials[loss_value].append(trial_assignment) - skopt_suggested.append(trial_assignment) - loss_for_skopt.append(loss_value) - elif trial_assignment not in self.recorded_trials[loss_value]: - self.recorded_trials[loss_value].append(trial_assignment) + if trial.name not in self.recorded_trials_names: + self.recorded_trials_names.append(trial.name) + trial_assignment = [] + for param in self.search_space.params: + parameter_value = None + for assignment in trial.assignments: + if assignment.name == param.name: + parameter_value = assignment.value + break + if param.type == INTEGER: + trial_assignment.append(int(parameter_value)) + elif param.type == DOUBLE: + trial_assignment.append(float(parameter_value)) + else: + trial_assignment.append(parameter_value) skopt_suggested.append(trial_assignment) + loss_value = float(trial.target_metric.value) + if self.search_space.goal == MAX_GOAL: + loss_value = -1 * loss_value loss_for_skopt.append(loss_value) if loss_for_skopt != [] and skopt_suggested != []: logger.info("Running Optimizer tell to record observation") logger.info("Evaluated parameters: {}".format(skopt_suggested)) logger.info("Objective values: {}\n".format(loss_for_skopt)) + t1 = datetime.datetime.now() self.skopt_optimizer.tell(skopt_suggested, loss_for_skopt) + logger.info("Optimizer tell method takes {} seconds".format((datetime.datetime.now()-t1).seconds)) + logger.info("List of recorded Trials names: {}\n".format(self.recorded_trials_names)) else: logger.info("Succeeded Trials didn't change: {}\n".format(self.succeeded_trials)) From 4cbc13db7c15ab402397ed6adc749cead7b8a3f0 Mon Sep 17 00:00:00 2001 From: avelichk Date: Wed, 19 Feb 2020 18:21:37 +0000 Subject: [PATCH 10/10] Get search space only for the first run --- pkg/suggestion/v1alpha3/skopt_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/suggestion/v1alpha3/skopt_service.py b/pkg/suggestion/v1alpha3/skopt_service.py index f7dc96950ca..6094dd2b7d9 100644 --- a/pkg/suggestion/v1alpha3/skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt_service.py @@ -27,8 +27,8 @@ def GetSuggestions(self, request, context): if algorithm_name != "bayesianoptimization": raise Exception("Failed to create the algortihm: {}".format(algorithm_name)) - search_space = HyperParameterSearchSpace.convert(request.experiment) if self.is_first_run: + search_space = HyperParameterSearchSpace.convert(request.experiment) self.base_service = BaseSkoptService( base_estimator=config.base_estimator, n_initial_points=config.n_initial_points,