SheffieldML / GPyOpt

Gaussian Process Optimization using GPy
BSD 3-Clause "New" or "Revised" License
927 stars 261 forks source link

Problems using GP_MCMC #260

Open dchoangnguyen opened 5 years ago

dchoangnguyen commented 5 years ago

Dear Javier, currently I am working on an optimization of hyperparameters for solving the traveling salesman problem with a heuristic for my masterthesis. Therefore I am using GPyOpt. The normal GP is working. I tried to use GP_MCMC for a better fit of the GP hyperparameters with these settings:

myBopt = BayesianOptimization(f=Optimization.RadiusFunction, model_type='GP_MCMC', acquistion_type='EI_MCMC', acquisition_optimizer_type='lbfgs', normalize_Y=True, n_samples=5, domain=domain, exact_feval=False) myBopt.run_optimization(max_iter=1250, max_time=None, verbosity=True, evaluations_file='eval.txt', report_file='report.txt', models_file='models.txt')

Resulting in this error:

reconstraining parameters GP_regression.rbf reconstraining parameters GP_regression.Gaussian_noise.variance Traceback (most recent call last): File "C:/Users/Duc Hoang/Desktop/Masterarbeit/Optimization", line 96, in models_file='models.txt') File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\core\bo.py", line 143, in run_optimization self.suggested_sample = self._compute_next_evaluations() File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\core\bo.py", line 234, in _compute_next_evaluations return self.space.zip_inputs(self.evaluator.compute_batch(duplicate_manager=duplicate_manager, context_manager= self.acquisition.optimizer.context_manager)) File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\core\evaluators\sequential.py", line 22, in computebatch x, = self.acquisition.optimize(duplicate_manager=duplicate_manager) File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\acquisitions\base.py", line 59, in optimize out = self.optimizer.optimize(f=self.acquisition_function, f_df=self.acquisition_function_withGradients, duplicate_manager=duplicate_manager) File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\optimization\acquisition_optimizer.py", line 69, in optimize anchor_points = anchor_points_generator.get(duplicate_manager=duplicate_manager, context_manager=self.context_manager) File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\optimization\anchor_points_generator.py", line 59, in get scores = self.get_anchor_point_scores(X) File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\optimization\anchor_points_generator.py", line 98, in get_anchor_point_scores return self.objective(X).flatten() File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\acquisitions\base.py", line 37, in acquisition_function f_acqu = self._compute_acq(x) File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\acquisitions\EI.py", line 38, in _compute_acq phi, Phi, u = get_quantiles(self.jitter, fmin, m, s) File "C:\Users\Duc Hoang\AppData\Local\Programs\Python\Python36\lib\site-packages\GPyOpt\util\general.py", line 123, in get_quantiles elif s< 1e-10: TypeError: '<' not supported between instances of 'list' and 'float'

In addition, I am using these package versions:

GPy 1.9.6 GPyOpt 1.2.5 matplotlib 3.0.3 numpy 1.15.4 paramz 0.9.4 scipy 1.2.1

with Python 3.6. Thanks in advance!

ernstklrb commented 4 years ago

This error is a result of the acquisition_type being inconsistent with the model_type. When you just change model_type to 'GP_MCMC' it will fail with the default acquisition_type 'EI'. You also have to change the acquisition_type to, e.g., 'EI_MCMC'.

I find the library could and should automatically switch to the appropriate non-MCMC or MCMC version of an acquisition function.