[tune] Initial Commit for Tune CLI (#3983)

This introduces a light CLI for Tune.
This commit is contained in:
Richard Liaw
2019-03-08 16:46:05 -08:00
committed by GitHub
parent 3064fad96b
commit 6630a35353
18 changed files with 492 additions and 69 deletions
+9 -5
View File
@@ -4,13 +4,16 @@ from __future__ import print_function
import copy
try:
import bayes_opt as byo
except Exception:
byo = None
from ray.tune.suggest.suggestion import SuggestionAlgorithm
byo = None
def _import_bayesopt():
global byo
import bayes_opt
byo = bayes_opt
class BayesOptSearch(SuggestionAlgorithm):
"""A wrapper around BayesOpt to provide trial suggestions.
@@ -56,6 +59,7 @@ class BayesOptSearch(SuggestionAlgorithm):
random_state=1,
verbose=0,
**kwargs):
_import_bayesopt()
assert byo is not None, (
"BayesOpt must be installed!. You can install BayesOpt with"
" the command: `pip install bayesian-optimization`.")
+12 -8
View File
@@ -6,17 +6,19 @@ import numpy as np
import copy
import logging
try:
hyperopt_logger = logging.getLogger("hyperopt")
hyperopt_logger.setLevel(logging.WARNING)
import hyperopt as hpo
from hyperopt.fmin import generate_trials_to_calculate
except Exception:
hpo = None
from ray.tune.error import TuneError
from ray.tune.suggest.suggestion import SuggestionAlgorithm
hpo = None
def _import_hyperopt():
global hpo
hyperopt_logger = logging.getLogger("hyperopt")
hyperopt_logger.setLevel(logging.WARNING)
import hyperopt
hpo = hyperopt
class HyperOptSearch(SuggestionAlgorithm):
"""A wrapper around HyperOpt to provide trial suggestions.
@@ -73,7 +75,9 @@ class HyperOptSearch(SuggestionAlgorithm):
reward_attr="episode_reward_mean",
points_to_evaluate=None,
**kwargs):
_import_hyperopt()
assert hpo is not None, "HyperOpt must be installed!"
from hyperopt.fmin import generate_trials_to_calculate
assert type(max_concurrent) is int and max_concurrent > 0
self._max_concurrent = max_concurrent
self._reward_attr = reward_attr