I am using bayesian optimization to optimize the hyper parameters of a NN using python library "bayes_opt", but an error has raised
~\Miniconda3\envs\tensorflow\lib\site-packages\bayes_opt\bayesian_optimization.py in next(self) 25 if self.empty: ---> 26 raise StopIteration("Queue is empty, no more objects to retrieve.") 27 obj = self._queue[0]
StopIteration: Queue is empty, no more objects to retrieve.
My code is as following:
from bayes_opt import BayesianOptimization
import time
# Supress NaN warnings, see: https://stackoverflow.com/questions/34955158/what-might-be-the-cause-of-invalid-value-encountered-in-less-equal-in-numpy
import warnings
warnings.filterwarnings("ignore",category =RuntimeWarning)
# Bounded region of parameter space
pbounds = {'dropout': (0.0, 0.499),
'lr': (0.0, 0.1),
'neuronPct': (0.01, 1),
'neuronShrink': (0.01, 1)
}
optimizer = BayesianOptimization(
f=evaluate_network,
pbounds=pbounds,
verbose=2, # verbose = 1 prints only when a maximum is observed, verbose = 0 is silent
random_state=1,
)
start_time = time.time()
optimizer.maximize(init_points=10, n_iter=100,)
time_took = time.time() - start_time
print(optimizer.max)
and the output is as following:
| iter | target | dropout | lr | neuronPct | neuron... |
-------------------------------------------------------------------------
| 1 | -0.5718 | 0.2081 | 0.07203 | 0.01011 | 0.3093 |
| 2 | -0.5906 | 0.07323 | 0.009234 | 0.1944 | 0.3521 |
| 3 | -2.475 | 0.198 | 0.05388 | 0.425 | 0.6884 |
| 4 | -0.5708 | 0.102 | 0.08781 | 0.03711 | 0.6738 |
| 5 | -0.5749 | 0.2082 | 0.05587 | 0.149 | 0.2061 |
| 6 | -2.487 | 0.3996 | 0.09683 | 0.3203 | 0.6954 |
| 7 | -0.5669 | 0.4373 | 0.08946 | 0.09419 | 0.04866 |
| 8 | -0.5701 | 0.08475 | 0.08781 | 0.1074 | 0.4269 |
| 9 | -0.607 | 0.478 | 0.05332 | 0.695 | 0.3224 |
| 10 | -0.581 | 0.3426 | 0.08346 | 0.02811 | 0.7526 |
| 11 | -0.7295 | 0.1606 | 0.0 | 1.0 | 0.01 |
| 12 | -0.7131 | 0.499 | 0.0 | 0.607 | 0.01 |
| 13 | -0.7044 | 0.0 | 0.0 | 0.01 | 0.01 |
| 14 | -0.5872 | 0.04935 | 0.01347 | 0.4728 | 0.4246 |
| 15 | -0.5665 | 0.0 | 0.1 | 0.5566 | 0.01 |
| 16 | -0.9658 | 0.0 | 0.0 | 1.0 | 0.4938 |
| 17 | -0.9074 | 0.0 | 0.0 | 0.01 | 1.0 |
| 18 | -2.464 | 0.499 | 0.1 | 1.0 | 0.1975 |
| 19 | -0.9505 | 0.499 | 0.0 | 1.0 | 1.0 |
| 20 | nan | 0.0 | 0.1 | 1.0 | 1.0 |
NOTE the "nan" at the last row of the output table
Thanks in advance.