-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from nabenabe0928/refactor-hebo
Refactor `HEBOSampler` based on `TPESampler`
- Loading branch information
Showing
3 changed files
with
34 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,12 @@ license: MIT License | |
## Installation | ||
|
||
```bash | ||
pip install -r https://hub.optuna.org/samplers/hebo/requirements.txt | ||
git clone [email protected]:huawei-noah/HEBO.git | ||
cd HEBO/HEBO | ||
pip install -e . | ||
# Install the dependencies. | ||
pip install optunahub hebo | ||
|
||
# NOTE: Below is optional, but pymoo must be installed after NumPy for faster HEBOSampler, | ||
# we run the following command to make sure that the compiled version is installed. | ||
pip install --upgrade pymoo | ||
``` | ||
|
||
## APIs | ||
|
@@ -59,11 +61,7 @@ def objective(trial: optuna.trial.Trial) -> float: | |
|
||
|
||
module = optunahub.load_module("samplers/hebo") | ||
sampler = module.HEBOSampler(search_space={ | ||
"x": optuna.distributions.FloatDistribution(-10, 10), | ||
"y": optuna.distributions.IntDistribution(-10, 10), | ||
}) | ||
# sampler = module.HEBOSampler() # Note: `search_space` is not required, and thus it works too. | ||
sampler = module.HEBOSampler() | ||
study = optuna.create_study(sampler=sampler) | ||
study.optimize(objective, n_trials=100) | ||
|
||
|
@@ -73,6 +71,19 @@ print(study.best_trial.params, study.best_trial.value) | |
See [`example.py`](https://github.com/optuna/optunahub-registry/blob/main/package/samplers/hebo/example.py) for a full example. | ||
![History Plot](images/hebo_optimization_history.png "History Plot") | ||
|
||
Note that it may slightly speed up the sampling routine by giving the search space directly to `HEBOSampler` since Optuna can skip the search space inference. | ||
For example, the instantiation of `HEBOSampler` above can be modified as follows: | ||
|
||
```python | ||
search_space={ | ||
"x": optuna.distributions.FloatDistribution(-10, 10), | ||
"y": optuna.distributions.IntDistribution(-10, 10), | ||
} | ||
sampler = module.HEBOSampler(search_space=search_space) | ||
``` | ||
|
||
However, users need to make sure that the provided search space and the search space defined in the objective function must be consistent. | ||
|
||
## Others | ||
|
||
HEBO is the winning submission to the [NeurIPS 2020 Black-Box Optimisation Challenge](https://bbochallenge.com/leaderboard). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
optuna | ||
optunahub | ||
hebo@git+https://github.com/huawei-noah/[email protected]#subdirectory=HEBO | ||
hebo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters