mirror of
https://github.com/wassname/ray.git
synced 2026-09-10 12:38:43 +08:00
[tune] Initial Commit for Tune CLI (#3983)
This introduces a light CLI for Tune.
This commit is contained in:
@@ -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`.")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user