diff --git a/examples/v1beta1/hp-tuning/hyperopt-distribution.yaml b/examples/v1beta1/hp-tuning/hyperopt-distribution.yaml index 5d0a25c6f3d..f78e39ff3c7 100644 --- a/examples/v1beta1/hp-tuning/hyperopt-distribution.yaml +++ b/examples/v1beta1/hp-tuning/hyperopt-distribution.yaml @@ -11,9 +11,9 @@ spec: objectiveMetricName: loss algorithm: algorithmName: random - parallelTrialCount: 2 - maxTrialCount: 2 - maxFailedTrialCount: 2 + parallelTrialCount: 3 + maxTrialCount: 12 + maxFailedTrialCount: 3 parameters: - name: lr parameterType: double diff --git a/pkg/suggestion/v1beta1/hyperopt/base_service.py b/pkg/suggestion/v1beta1/hyperopt/base_service.py index 5b2c3d042a0..a46aa2476cf 100644 --- a/pkg/suggestion/v1beta1/hyperopt/base_service.py +++ b/pkg/suggestion/v1beta1/hyperopt/base_service.py @@ -64,83 +64,7 @@ def create_hyperopt_domain(self): # hyperopt.hp.uniform('x2', -10, 10)} hyperopt_search_space = {} for param in self.search_space.params: - if param.type == INTEGER: - if param.distribution == api_pb2.UNIFORM or param.distribution is None: - if param.step: - hyperopt_search_space[param.name] = int( - hyperopt.hp.quniform( - param.name, - float(param.min), - float(param.max), - float(param.step), - ) - ) - else: - hyperopt_search_space[param.name] = int( - hyperopt.hp.uniformint( - param.name, float(param.min), float(param.max) - ) - ) - elif param.distribution == api_pb2.LOG_UNIFORM: - if param.step: - hyperopt_search_space[param.name] = hyperopt.hp.qloguniform( - param.name, - math.log(float(param.min)), - math.log(float(param.max)), - float(param.step), - ) - else: - hyperopt_search_space[param.name] = hyperopt.hp.loguniform( - param.name, - math.log(float(param.min)), - math.log(float(param.max)), - ) - elif param.distribution == api_pb2.NORMAL: - mu = (float(param.min) + float(param.max)) / 2 - sigma = (float(param.max) - float(param.min)) / 6 - - if param.step: - hyperopt_search_space[param.name] = int( - hyperopt.hp.qnormal( - param.name, - mu, - sigma, - float(param.step), - ) - ) - else: - hyperopt_search_space[param.name] = int( - hyperopt.hp.normal( - param.name, - mu, - sigma, - ) - ) - elif param.distribution == api_pb2.LOG_NORMAL: - log_min = math.log(float(param.min)) - log_max = math.log(float(param.max)) - - mu = (log_min + log_max) / 2 - sigma = (log_max - log_min) / 6 - - if param.step: - hyperopt_search_space[param.name] = int( - hyperopt.hp.qlognormal( - param.name, - mu, - sigma, - float(param.step), - ) - ) - else: - hyperopt_search_space[param.name] = int( - hyperopt.hp.lognormal( - param.name, - mu, - sigma, - ) - ) - elif param.type == DOUBLE: + if param.type in [INTEGER, DOUBLE]: if param.distribution == api_pb2.UNIFORM or param.distribution is None: if param.step: hyperopt_search_space[param.name] = hyperopt.hp.quniform( @@ -150,9 +74,14 @@ def create_hyperopt_domain(self): float(param.step), ) else: - hyperopt_search_space[param.name] = hyperopt.hp.uniform( - param.name, float(param.min), float(param.max) - ) + if param.type == INTEGER: + hyperopt_search_space[param.name] = hyperopt.hp.uniformint( + param.name, float(param.min), float(param.max) + ) + else: + hyperopt_search_space[param.name] = hyperopt.hp.uniform( + param.name, float(param.min), float(param.max) + ) elif param.distribution == api_pb2.LOG_UNIFORM: if param.step: hyperopt_search_space[param.name] = hyperopt.hp.qloguniform(