dragonfly / dragonfly

An open source python library for scalable Bayesian optimisation.
MIT License
852 stars 231 forks source link

Errors encountered when using Dragonfly #1 (Abortive) #33

Open alelasantillan opened 5 years ago

alelasantillan commented 5 years ago

I implemented successfuly the library and I try it several times. The library went through the initialization process perfectly well in all trials. After that it never completed the process (capital 200) en exited with this error (OverflowError: int too large to convert to float)

There were two kinds of errors: those interrupting the execution and those where execution continued. I will begin by showing on of the fatal ones. The process run two more loops before getting this, which I don't know what could mean. Any idea?

stable_cholesky failed with diag_noise_power=-8. stable_cholesky failed with diag_noise_power=-7. stable_cholesky failed with diag_noise_power=-6. stable_cholesky failed with diag_noise_power=-5. stable_cholesky failed with diag_noise_power=-4. stable_cholesky failed with diag_noise_power=-3. stable_cholesky failed with diag_noise_power=-2. stable_cholesky failed with diag_noise_power=-1. stable_cholesky failed with diag_noise_power=0. stable_cholesky failed with diag_noise_power=1. stable_cholesky failed with diag_noise_power=2. stable_cholesky failed with diag_noise_power=3. stable_cholesky failed with diag_noise_power=4. **** Cholesky failed: Added diag noise = -8.846730e-10 stable_cholesky failed with diag_noise_power=5. **** Cholesky failed: Added diag noise = -8.846730e-10 stable_cholesky failed with diag_noise_power=6. **** Cholesky failed: Added diag noise = -8.846730e-10 stable_cholesky failed with diag_noise_power=7. ... ... ... ... edited for readability, it just repeate the line before augmenting diag_noise_power value.

... ... ... stable_cholesky failed with diag_noise_power=306. **** Cholesky failed: Added diag noise = -8.846730e-10 /Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/utils/general_utils.py:189: RuntimeWarning: overflow encountered in multiply ((10diag_noise_power) max_M) np.eye(M.shape[0])) stable_cholesky failed with diag_noise_power=307. ** Cholesky failed: Added diag noise = -8.846730e-10 stable_cholesky failed with diag_noise_power=308. **** Cholesky failed: Added diag noise = -8.846730e-10 Traceback (most recent call last): File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/utils/general_utils.py", line 177, in stable_cholesky L = np.linalg.cholesky(M) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/numpy/linalg/linalg.py", line 733, in cholesky r = gufunc(a, signature=signature, extobj=extobj) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/numpy/linalg/linalg.py", line 92, in _raise_linalgerror_nonposdef raise LinAlgError("Matrix is not positive definite") numpy.linalg.linalg.LinAlgError: Matrix is not positive definite

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "in_code_demo_alela2.py", line 36, in main() File "in_code_demo_alela2.py", line 31, in main opt_val, optpt, = minimise_function(my_func_to_minimize, config.domain, max_capital, config=config) #alela File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/apis/opt.py", line 215, in minimise_function max_val, opt_pt, history = maximise_function(func_to_max, *args, *kwargs) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/apis/opt.py", line 178, in maximise_function max_capital, is_mf=False, options=options, reporter=reporter) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/opt/gp_bandit.py", line 1000, in gpb_from_func_caller return optimiser.optimise(max_capital) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/opt/blackbox_optimiser.py", line 189, in optimise return self.run_experiments(max_capital) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/exd/exd_core.py", line 536, in run_experiments self._asynchronous_run_experiment_routine() File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/exd/exd_core.py", line 491, in _asynchronous_run_experiment_routine qinfo = self._determine_next_query() File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/opt/gp_bandit.py", line 495, in _determine_next_query next_eval_point = select_pt_func(self.gp, anc_data) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/opt/gpb_acquisitions.py", line 127, in asy_ts return maximise_acquisition(gp_sample, anc_data, vectorised=True) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/opt/gpb_acquisitions.py", line 39, in maximise_acquisition anc_data.max_evals, args, *kwargs) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/exd/exd_utils.py", line 172, in maximise_with_method return_history, args, kwargs) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/exd/exd_utils.py", line 272, in maximise_with_method_on_cp_domain return_history) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/exd/exd_utils.py", line 248, in _rand_maximise_vectorised_objective_in_cp_domain rand_values = [obj(x) for x in rand_samples] File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/exd/exd_utils.py", line 248, in rand_values = [obj(x) for x in rand_samples] File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/opt/gpb_acquisitions.py", line 37, in acquisition = lambda x: acq_fn([x]) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/opt/gpb_acquisitions.py", line 78, in return lambda x: _gp.draw_samples(1, x).ravel() File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/gp/gp_core.py", line 251, in draw_samples return draw_gaussian_samples(num_samples, mean_vals, covar) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/utils/general_utils.py", line 222, in draw_gaussian_samples L = stable_cholesky(K) File "/Users/alejandrosantillaniturres/Desktop/programming/python/virtualenv_ataa/lib/python3.7/site-packages/dragonfly/utils/general_utils.py", line 189, in stable_cholesky ((10diag_noise_power) max_M) np.eye(M.shape[0])) OverflowError: int too large to convert to float

kirthevasank commented 5 years ago

All of these errors are symptomatic of the function to optimise returning infinities or nans.

alelasantillan commented 5 years ago

Thank you kirthevasank, I will check that out. Anyway the function to optimize shows on the screen the value to be returned to minimise function, and is always a number between 0 and 30. Any idea what else to check?

Below is the screen output before the error. The value 10.029269... is the value returned buy myfunc that executes function_to_optimize.py with the parameters shown at the right.

python function_to_optimize.py T 12 B 18 E 54 sigmasquare 5670 10.029269356567582 stable_cholesky failed with diag_noise_power=-8. stable_cholesky failed with diag_noise_power=-7. stable_cholesky failed with diag_noise_power=-6. stable_cholesky failed with diag_noise_power=-5. ...the error continues until it aborts

alelasantillan commented 5 years ago

I was able to replicate the error by doing this: 1 """ 2 demo that hangs dragonfly 3 """ 4 # pylint: disable=invalid-name 5 #from future import print_function 6 from dragonfly import maximise_function, minimise_function, load_config 7 # Local imports 8 from function import my_func_to_minimize #alela 9 10 def main(): 11 """ Main function. """ 12 #domain_bounds = [[-5, 10], [0, 15]] 13 #max_capital = 100 14 #domain_bounds = [[20070614,20070614], [8, 64], [4, 24], [8,64], [80,6400], [9,29]] 15 max_capital = 200 16 max_capital = 80 17 18 domain_vars = [{'name': 'date', 'type': 'int', 'min': 20070614, 'max': 20070614}, 19 {'name': 'T', 'type': 'int', 'min': 8, 'max': 64}, 20 {'name': 'B', 'type': 'int', 'min': 8, 'max': 24}, 21 {'name': 'E', 'type': 'int', 'min': 8, 'max': 64}, 22 {'name': 'sigmasquare', 'type': 'int', 'min': 80, 'max': 6400}, 23 {'name': 'DeltaT', 'type': 'int', 'min': 9, 'max': 29}] 24 config_params = {'domain': domain_vars} 25 config = load_config(config_params) 26 #opt_val, optpt, = maximise_function(branin, domain_bounds, max_capital) #alela 27 #opt_val, optpt, = minimise_function(my_func_to_minimize, domain_bounds, max_capital) #alela 28 opt_val, optpt, = minimise_function(my_func_to_minimize, config.domain, max_capital, config=config) #alela 29 print('Optimum Value in %d evals: %0.4f'%(max_capital, opt_val)) 30 print('Optimum Point: %s'%(opt_pt)) 31 32 if name == 'main': 33 main()

And the function is just a random number generator like this:

1 """ 2 function to minimize. I just return random numbers 3 """ 4 import random 5 6 def my_func_to_minimize(x): 7 date = x[0] 8 T = x[1] 9 B = x[2] 10 E = x[3] 11 sigmacuadrado = x[4] 12 DeltaT = x[5] 13 print("pameters received:",date,T,B,E,sigmacuadrado,DeltaT) 14 loss = random.uniform(1.5, 19) 15 print(loss) 16 return loss 17 18 def main(x): 19 """ Main function. """ 20 return my_func_to_minimize(x)

Doing this, all the described errors appear. In my opinion, though not sure, the problem is due to the date I am passing as a parameter, which is several orders of magnitude greater than the other parameters. When removed the parameter date, no more errors were present so far. I will close the other posts about the other errors pointing to this post.

kirthevasank commented 5 years ago

The data parameter's min and max values are the same, which makes it degenerate (if you only allow one value for the parameter, then why tune for it?). Can you check if the error disappears if you change this?

alelasantillan commented 5 years ago

Kirthevasank I've tested it with a range in the data parameter and it worked perfect, but still depend on the range of values. Using min=20070614 and max=20070615, it failed as before. Using a wider range: min=20070614 and max=20170614 it worked seamlessly.

kirthevasank commented 5 years ago

Ok, thanks for pointing this out. We'll take a look at this.

MohanadOdema commented 4 years ago

Hello,

Has the previous issue of small data ranges been addressed ? I'm trying a similar thing using the multiobjective hartmann experiment in the examples and I'm facing something similar.

I only edited the configuration file to currently have the first variable as "int" with "min":97 and "max":100, and the rest of the variables as boolean. (I also edited the normalization function in the corresponding multiobjective_hartmann.py to be suited to the new ranges).

The problem is that while the framework is operational, it starts to render repetitive pareto points and values. I attached several screenshots from my terminal showing the problem. I also tried different combinations of the domain variables but the problem persists and is more evident as the ranges get smaller.

multiobjective_prexample_working with boolean definition multiobjective_range 0,1 _repetition_issue_max multiobjective_repetition_problem_boolean+integral multiobjective_repetition_problem_boolean+integral2