[tune] Fix hpo randint limits (#11946)

Co-authored-by: Sumanth Ratna <sumanthratna@gmail.com>
This commit is contained in:
Kai Fricke
2020-11-12 17:45:49 +01:00
committed by GitHub
parent 07f401d99d
commit 02c02369ca
3 changed files with 5 additions and 15 deletions
+1 -11
View File
@@ -361,17 +361,7 @@ class HyperOptSearch(Searcher):
logger.warning(
"HyperOpt does not support quantization for "
"integer values. Reverting back to 'randint'.")
if domain.lower != 0:
raise ValueError(
"HyperOpt only allows integer sampling with "
f"lower bound 0. Got: {domain.lower}.")
if domain.upper < 1:
raise ValueError(
"HyperOpt does not support integer sampling "
"of values lower than 0. Set your maximum range "
"to something above 0 (currently {})".format(
domain.upper))
return hpo.hp.randint(par, domain.upper)
return hpo.hp.randint(par, domain.lower, high=domain.upper)
elif isinstance(domain, Categorical):
if isinstance(sampler, Uniform):
return hpo.hp.choice(par, [
+3 -3
View File
@@ -412,7 +412,7 @@ class SearchSpaceTest(unittest.TestCase):
config = {
"a": tune.sample.Categorical([2, 3, 4]).uniform(),
"b": {
"x": tune.sample.Integer(0, 5).quantized(2),
"x": tune.sample.Integer(-15, -10).quantized(2),
"y": 4,
"z": tune.sample.Float(1e-4, 1e-2).loguniform()
}
@@ -421,7 +421,7 @@ class SearchSpaceTest(unittest.TestCase):
hyperopt_config = {
"a": hp.choice("a", [2, 3, 4]),
"b": {
"x": hp.randint("x", 5),
"x": hp.randint("x", -15, -10),
"y": 4,
"z": hp.loguniform("z", np.log(1e-4), np.log(1e-2))
}
@@ -443,7 +443,7 @@ class SearchSpaceTest(unittest.TestCase):
self.assertEqual(config1, config2)
self.assertIn(config1["a"], [2, 3, 4])
self.assertIn(config1["b"]["x"], list(range(5)))
self.assertIn(config1["b"]["x"], list(range(-15, -10)))
self.assertEqual(config1["b"]["y"], 4)
self.assertLess(1e-4, config1["b"]["z"])
self.assertLess(config1["b"]["z"], 1e-2)
+1 -1
View File
@@ -7,7 +7,7 @@ gym[atari]
GPy
h5py
hpbandster
hyperopt==0.1.2
hyperopt>=0.2.5
jupyter
keras
kubernetes