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

how to optimize on integer-valued parameters? #133

Closed
overshiki opened this issue Aug 1, 2019 · 2 comments
Closed

how to optimize on integer-valued parameters? #133

overshiki opened this issue Aug 1, 2019 · 2 comments

Comments

@overshiki
Copy link

overshiki commented Aug 1, 2019

Hi,
I'm just brand new to this field.
Following the tutorial, I could very easily do the optimization on float-valued parameters such as learning rate. However, I couldn't find any guidance on integer-valued parameters, such as the number of layers and the number of neurons per layer.
A brief search lead me to the paper: https://arxiv.org/pdf/1706.03673.pdf which described 3 strategies:
1. optimize the float valued acquisition function and then wrap the result into the closest integer, before the evaluating step
2. optimize the float valued acquisition function, use this value as input to the evaluating function, then do the wrapping inside the evaluating function
2. do the wrapping of the input when calculating the covariance function

I am not sure if Ax or botorch has implemented any interface for integer inputs. If so, which strategy is used? or any other ideas are recommended here?

Thanks a lot in advance.

@sdaulton
Copy link
Contributor

sdaulton commented Aug 1, 2019

Hi @overshiki, you can specify that a RangeParameter is an integer using ParameterType.INT.. E.g. RangeParameter(name="x", parameter_type=ParameterType.INT, lower=1, upper=10). By default, Ax will apply an IntToFloat transform on generated candidates that basically does (1). You can see all the default transforms here. If you are generating batches of new candidates and you are using sequentially (greedy) selecting each point in the batch (the default in Ax), where each candidate in the batch is sequentially selected and subsequent candidates are conditioned upon the already selected points, then each new candidate is rounded before the successive conditioning to improve the optimization performance. The docs mention that you can use integer RangeParameters here, but I will add a better description as to the behavior.

@sdaulton sdaulton closed this as completed Aug 1, 2019
@sdaulton sdaulton reopened this Aug 1, 2019
@danielrjiang
Copy link
Contributor

Also, you can see how the transformation / untransformation happens before and after a point is generated here, similar to how you describe in (1):

Ax/ax/modelbridge/base.py

Lines 491 to 522 in 951aa7b

# Transform
for t in self.transforms.values():
search_space = t.transform_search_space(search_space)
if optimization_config is not None:
optimization_config = t.transform_optimization_config(
optimization_config=optimization_config,
modelbridge=self,
fixed_features=fixed_features,
)
for metric, po in pending_observations.items():
pending_observations[metric] = t.transform_observation_features(po)
fixed_features = t.transform_observation_features([fixed_features])[0]
# Apply terminal transform and gen
observation_features, weights, best_obsf = self._gen(
n=n,
search_space=search_space,
optimization_config=optimization_config,
pending_observations=pending_observations,
fixed_features=fixed_features,
model_gen_options=model_gen_options,
)
# Apply reverse transforms
# pyre-fixme[6]: Expected `Sequence[_T]` for 1st param but got `ValuesView[Tr...
for t in reversed(self.transforms.values()): # noqa T484
observation_features = t.untransform_observation_features(
observation_features
)
if best_obsf is not None:
best_obsf = t.untransform_observation_features([best_obsf])[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants