Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support step for int parameter in Chocolate and Hyperopt Suggestion #1123

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def getSuggestions(self, search_space, trials, request_number):
key = BaseChocolateService.encode(param.name)
if param.type == INTEGER:
chocolate_search_space[key] = choco.quantized_uniform(
int(param.min), int(param.max), 1)
int(param.min), int(param.max), int(param.step))
elif param.type == DOUBLE:
chocolate_search_space[key] = choco.quantized_uniform(
float(param.min), float(param.max), float(param.step))
Expand Down
3 changes: 2 additions & 1 deletion pkg/suggestion/v1alpha3/hyperopt/base_hyperopt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def create_hyperopt_domain(self):
hyperopt_search_space[param.name] = hyperopt.hp.quniform(
param.name,
float(param.min),
float(param.max), 1)
float(param.max),
float(param.step))
elif param.type == DOUBLE:
hyperopt_search_space[param.name] = hyperopt.hp.uniform(
param.name,
Expand Down
10 changes: 7 additions & 3 deletions pkg/suggestion/v1alpha3/internal/search_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ def __str__(self):
@staticmethod
def convertParameter(p):
if p.parameter_type == api.INT:
return HyperParameter.int(p.name, p.feasible_space.min, p.feasible_space.max)
# Default value for INT parameter step is 1
step = 1
if p.feasible_space.step != None and p.feasible_space.step != "":
step = p.feasible_space.step
return HyperParameter.int(p.name, p.feasible_space.min, p.feasible_space.max, step)
elif p.parameter_type == api.DOUBLE:
return HyperParameter.double(p.name, p.feasible_space.min, p.feasible_space.max, p.feasible_space.step)
elif p.parameter_type == api.CATEGORICAL:
Expand Down Expand Up @@ -67,8 +71,8 @@ def __str__(self):
self.name, self.type, ", ".join(self.list))

@staticmethod
def int(name, min_, max_):
return HyperParameter(name, INTEGER, min_, max_, [], 0)
def int(name, min_, max_, step):
return HyperParameter(name, INTEGER, min_, max_, [], step)

@staticmethod
def double(name, min_, max_, step):
Expand Down