[tune] Add algorithms for search space conversion (#10621)

This commit is contained in:
Kai Fricke
2020-09-07 13:44:16 -07:00
committed by GitHub
parent 99625d0bce
commit 088f8ebb69
14 changed files with 1205 additions and 258 deletions
+29 -27
View File
@@ -31,9 +31,6 @@ def objective(config):
if __name__ == "__main__":
import argparse
from dragonfly.opt.gp_bandit import EuclideanGPBandit
from dragonfly.exd.experiment_caller import EuclideanFunctionCaller
from dragonfly import load_config
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -41,40 +38,45 @@ if __name__ == "__main__":
args, _ = parser.parse_known_args()
ray.init()
config = {
tune_kwargs = {
"num_samples": 10 if args.smoke_test else 50,
"config": {
"iterations": 100,
"LiNO3_vol": tune.uniform(0, 7),
"Li2SO4_vol": tune.uniform(0, 7),
"NaClO4_vol": tune.uniform(0, 7)
},
}
domain_vars = [{
"name": "LiNO3_vol",
"type": "float",
"min": 0,
"max": 7
}, {
"name": "Li2SO4_vol",
"type": "float",
"min": 0,
"max": 7
}, {
"name": "NaClO4_vol",
"type": "float",
"min": 0,
"max": 7
}]
# Optional: Pass the parameter space yourself
# space = [{
# "name": "LiNO3_vol",
# "type": "float",
# "min": 0,
# "max": 7
# }, {
# "name": "Li2SO4_vol",
# "type": "float",
# "min": 0,
# "max": 7
# }, {
# "name": "NaClO4_vol",
# "type": "float",
# "min": 0,
# "max": 7
# }]
domain_config = load_config({"domain": domain_vars})
df_search = DragonflySearch(
optimizer="bandit",
domain="euclidean",
# space=space, # If you want to set the space manually
metric="objective",
mode="max")
func_caller = EuclideanFunctionCaller(
None, domain_config.domain.list_of_domains[0])
optimizer = EuclideanGPBandit(func_caller, ask_tell_mode=True)
algo = DragonflySearch(optimizer, metric="objective", mode="max")
scheduler = AsyncHyperBandScheduler(metric="objective", mode="max")
tune.run(
objective,
name="dragonfly_search",
search_alg=algo,
search_alg=df_search,
scheduler=scheduler,
**config)
**tune_kwargs)