[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
+13 -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 SigOptSearch
@@ -36,8 +36,6 @@ if __name__ == "__main__":
args, _ = parser.parse_known_args()
ray.init()
register_trainable("exp", easy_objective)
space = [
{
'name': 'width',
@@ -58,16 +56,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 = SigOptSearch(
space,
@@ -75,4 +70,8 @@ if __name__ == "__main__":
max_concurrent=1,
reward_attr="neg_mean_loss")
scheduler = AsyncHyperBandScheduler(reward_attr="neg_mean_loss")
run_experiments(config, search_alg=algo, scheduler=scheduler)
run(easy_objective,
name="my_exp",
search_alg=algo,
scheduler=scheduler,
**config)