Skip to content

Commit e2a6941

Browse files
committed
option to ignore crashes (no np.inf loss)
1 parent 397850c commit e2a6941

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

hpbandster/optimizers/bohb.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, configspace = None,
1818
eta=3, min_budget=0.01, max_budget=1,
1919
min_points_in_model = None, top_n_percent=15,
2020
num_samples = 64, random_fraction=1/3, bandwidth_factor=3,
21-
min_bandwidth=1e-3,
21+
min_bandwidth=1e-3, ignore_crashes=False,
2222
**kwargs ):
2323
"""
2424
BOHB performs robust and efficient hyperparameter optimization
@@ -88,7 +88,8 @@ def __init__(self, configspace = None,
8888
num_samples = num_samples,
8989
random_fraction=random_fraction,
9090
bandwidth_factor=bandwidth_factor,
91-
min_bandwidth = min_bandwidth
91+
min_bandwidth = min_bandwidth,
92+
ignore_crashes=ignore_crashes
9293
)
9394

9495
super().__init__(config_generator=cg, **kwargs)

hpbandster/optimizers/config_generators/bohb.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class BOHB(base_config_generator):
1818
def __init__(self, configspace, min_points_in_model = None,
1919
top_n_percent=15, num_samples = 64, random_fraction=1/3,
20-
bandwidth_factor=3, min_bandwidth=1e-3,
20+
bandwidth_factor=3, min_bandwidth=1e-3, ignore_crashes=False,
2121
**kwargs):
2222
"""
2323
Fits for each given budget a kernel density estimator on the best N percent of the
@@ -50,6 +50,7 @@ def __init__(self, configspace, min_points_in_model = None,
5050
self.configspace = configspace
5151
self.bw_factor = bandwidth_factor
5252
self.min_bandwidth = min_bandwidth
53+
self.ignore_crashes = ignore_crashes
5354

5455
self.min_points_in_model = min_points_in_model
5556
if min_points_in_model is None:
@@ -284,6 +285,8 @@ def new_result(self, job, update_model=True):
284285

285286
if job.result is None:
286287
# One could skip crashed results, but we decided to
288+
if self.ignore_crashes:
289+
return
287290
# assign a +inf loss and count them as bad configurations
288291
loss = np.inf
289292
else:

0 commit comments

Comments
 (0)