mirror of
https://github.com/wassname/ray.git
synced 2026-09-11 12:43:20 +08:00
[tune] Add seed parameter to BOHB (#12160)
This commit is contained in:
@@ -48,6 +48,9 @@ class TuneBOHB(Searcher):
|
||||
metric (str): The training result objective value attribute.
|
||||
mode (str): One of {min, max}. Determines whether objective is
|
||||
minimizing or maximizing the metric attribute.
|
||||
seed (int): Optional random seed to initialize the random number
|
||||
generator. Setting this should lead to identical initial
|
||||
configurations at each run.
|
||||
|
||||
Tune automatically converts search spaces to TuneBOHB's format:
|
||||
|
||||
@@ -100,7 +103,8 @@ class TuneBOHB(Searcher):
|
||||
bohb_config: Optional[Dict] = None,
|
||||
max_concurrent: int = 10,
|
||||
metric: Optional[str] = None,
|
||||
mode: Optional[str] = None):
|
||||
mode: Optional[str] = None,
|
||||
seed: Optional[int] = None):
|
||||
from hpbandster.optimizers.config_generators.bohb import BOHB
|
||||
assert BOHB is not None, "HpBandSter must be installed!"
|
||||
if mode:
|
||||
@@ -122,6 +126,7 @@ class TuneBOHB(Searcher):
|
||||
space = self.convert_search_space(space)
|
||||
|
||||
self._space = space
|
||||
self._seed = seed
|
||||
|
||||
super(TuneBOHB, self).__init__(metric=self._metric, mode=mode)
|
||||
|
||||
@@ -136,6 +141,9 @@ class TuneBOHB(Searcher):
|
||||
elif self._mode == "min":
|
||||
self._metric_op = 1.
|
||||
|
||||
if self._seed is not None:
|
||||
self._space.seed(self._seed)
|
||||
|
||||
bohb_config = self._bohb_config or {}
|
||||
self.bohber = BOHB(self._space, **bohb_config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user