[tune] Simplify API (#4234)

Uses `tune.run` to execute experiments as preferred API.

@noahgolmant

This does not break backwards compat, but will slowly internalize `Experiment`. 

In a separate PR, Tune schedulers should only support 1 running experiment at a time.
This commit is contained in:
Richard Liaw
2019-03-17 13:03:32 -07:00
committed by GitHub
parent 20a155d03d
commit ea5a6f8455
34 changed files with 523 additions and 589 deletions
+9 -14
View File
@@ -7,7 +7,7 @@ from __future__ import division
from __future__ import print_function
import ray
from ray.tune import run_experiments, register_trainable
from ray.tune import run
from ray.tune.schedulers import AsyncHyperBandScheduler
from ray.tune.suggest import HyperOptSearch
@@ -35,8 +35,6 @@ if __name__ == "__main__":
args, _ = parser.parse_known_args()
ray.init()
register_trainable("exp", easy_objective)
space = {
'width': hp.uniform('width', 0, 20),
'height': hp.uniform('height', -100, 100),
@@ -57,16 +55,13 @@ if __name__ == "__main__":
]
config = {
"my_exp": {
"run": "exp",
"num_samples": 10 if args.smoke_test else 1000,
"config": {
"iterations": 100,
},
"stop": {
"timesteps_total": 100
},
}
"num_samples": 10 if args.smoke_test else 1000,
"config": {
"iterations": 100,
},
"stop": {
"timesteps_total": 100
},
}
algo = HyperOptSearch(
space,
@@ -74,4 +69,4 @@ if __name__ == "__main__":
reward_attr="neg_mean_loss",
points_to_evaluate=current_best_params)
scheduler = AsyncHyperBandScheduler(reward_attr="neg_mean_loss")
run_experiments(config, search_alg=algo, scheduler=scheduler)
run(easy_objective, search_alg=algo, scheduler=scheduler, **config)