Skip to content

Commit 47dabc6

Browse files
PhMuellerKEggensperger
authored andcommitted
Fix Inf Values in PYBNN Benchmark (#114)
* Fix a bug in the pybnn benchmarks. Limit the variance before computing the nll. (inf otherwise)
1 parent 1b8f281 commit 47dabc6

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

changelog.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
* We also change the configuration file. The container does not read the yaml file anymore. Instead we bind the
99
cache dir, data dir and socket dir into the container and let the container use them directly. We also remove the
1010
global data directory and use only the data dir from now onwards.
11-
* Add the surrogate SVM on MNIST benchmark from the BOHB paper.
12-
11+
* Add the surrogate SVM on MNIST benchmark from the BOHB paper.
12+
* Fix an error in PyBnn Benchmark:
13+
We introduce the benchmark version 0.0.4.
14+
In this new version, we prevent infinity values in the nll loss when the predicted variance
15+
is 0. We set the predicted variance before computing the log to max(var, 1e-10)
16+
1317
# 0.0.7
1418
* Fix an error in the NASBench1shot1 Benchmark (SearchSpace3).
1519
* Improve the behavior when a benchmark container is shut down.

ci_scripts/install_singularity.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ make -C builddir && \
3232
sudo make -C builddir install
3333

3434
cd ..
35-
pip install .[singulaity]
35+
pip install .

hpobench/benchmarks/ml/pybnn.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
1111
Changelog:
1212
==========
13+
0.0.4
14+
* Limit variance in NLL loss to prevent very large values.
15+
1316
0.0.3
1417
* New container release due to a general change in the communication between container and HPOBench.
1518
Works with HPOBench >= v0.0.8
@@ -51,7 +54,7 @@
5154
from sgmcmc.bnn.lasagne_layers import AppendLayer # noqa: E402
5255

5356

54-
__version__ = '0.0.3'
57+
__version__ = '0.0.4'
5558
logger = logging.getLogger('PyBnnBenchmark')
5659

5760

@@ -220,6 +223,7 @@ def objective_function_test(self, configuration: Union[Dict, CS.Configuration],
220223
@staticmethod
221224
def _neg_log_likelihood(targets: np.ndarray, mean_pred: np.ndarray, var_pred: np.ndarray) -> np.ndarray:
222225
""" Compute the negative log likelihood for normal distributions. """
226+
var_pred = np.clip(var_pred, a_min=1e-10, a_max=np.inf)
223227
nll = [stats.norm.logpdf(targets[i], loc=mean_pred[i], scale=np.sqrt(var_pred[i]))
224228
for i in range(targets.shape[0])]
225229
return -np.mean(nll)

hpobench/container/benchmarks/ml/pybnn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ class BNNOnToyFunction(AbstractBenchmarkClient):
1010
def __init__(self, **kwargs):
1111
kwargs['benchmark_name'] = kwargs.get('benchmark_name', 'BNNOnToyFunction')
1212
kwargs['container_name'] = kwargs.get('container_name', 'pybnn')
13-
kwargs['latest'] = kwargs.get('container_tag', '0.0.3')
13+
kwargs['latest'] = kwargs.get('container_tag', '0.0.4')
1414
super(BNNOnToyFunction, self).__init__(**kwargs)
1515

1616

1717
class BNNOnBostonHousing(AbstractBenchmarkClient):
1818
def __init__(self, **kwargs):
1919
kwargs['benchmark_name'] = kwargs.get('benchmark_name', 'BNNOnBostonHousing')
2020
kwargs['container_name'] = kwargs.get('container_name', 'pybnn')
21-
kwargs['latest'] = kwargs.get('container_tag', '0.0.3')
21+
kwargs['latest'] = kwargs.get('container_tag', '0.0.4')
2222
super(BNNOnBostonHousing, self).__init__(**kwargs)
2323

2424

2525
class BNNOnProteinStructure(AbstractBenchmarkClient):
2626
def __init__(self, **kwargs):
2727
kwargs['benchmark_name'] = kwargs.get('benchmark_name', 'BNNOnProteinStructure')
2828
kwargs['container_name'] = kwargs.get('container_name', 'pybnn')
29-
kwargs['latest'] = kwargs.get('container_tag', '0.0.3')
29+
kwargs['latest'] = kwargs.get('container_tag', '0.0.4')
3030
super(BNNOnProteinStructure, self).__init__(**kwargs)
3131

3232

3333
class BNNOnYearPrediction(AbstractBenchmarkClient):
3434
def __init__(self, **kwargs):
3535
kwargs['benchmark_name'] = kwargs.get('benchmark_name', 'BNNOnYearPrediction')
3636
kwargs['container_name'] = kwargs.get('container_name', 'pybnn')
37-
kwargs['latest'] = kwargs.get('container_tag', '0.0.3')
37+
kwargs['latest'] = kwargs.get('container_tag', '0.0.4')
3838
super(BNNOnYearPrediction, self).__init__(**kwargs)

0 commit comments

Comments
 (0)