[tune] Add seed parameter to BOHB (#12160)

This commit is contained in:
Kai Fricke
2020-11-19 10:27:16 -08:00
committed by GitHub
parent dab241dcc6
commit 6999075c75
2 changed files with 36 additions and 10 deletions
+9 -1
View File
@@ -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)