GPyOpt を試していたのですが、最初のサンプルでいきなりコケたので、その解決方法のメモ。
もくじ
環境
* Windows 10 * Python 3.5 * GPyOpt v1.0.3
エラー内容
とてもシンプルなコードでエラー。
sheffieldml.github.io
C:\>python gpyopt_test.py Traceback (most recent call last): File "gpyopt_test.py", line 11, in <module> myBopt.run_optimization(max_iter=15) File "C:\Users\ssjb\AppData\Local\Programs\Python\Python35\lib\site-packages\GPyOpt\methods\bayesian_optimization.py", line 458, in run_optimization super(BayesianOptimization, self).run_optimization(max_iter = max_iter, max_time = max_time, eps = eps, verbosity=verbosity, save_models_parameters = save_models_parameters, report_file = report_file, evaluations_file= evaluations_file, models_file=models_file) File "C:\Users\ssjb\AppData\Local\Programs\Python\Python35\lib\site-packages\GPyOpt\core\bo.py", line 103, in run_optimization self._update_model() File "C:\Users\ssjb\AppData\Local\Programs\Python\Python35\lib\site-packages\GPyOpt\core\bo.py", line 198, in _update_model self._save_model_parameter_values() File "C:\Users\ssjb\AppData\Local\Programs\Python\Python35\lib\site-packages\GPyOpt\core\bo.py", line 209, in _save_model_parameter_values if self.model_parameters_iterations == None: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
解決方法
GPyOpt/core/bo.py
の209行目を修正します。
def _save_model_parameter_values(self): - if self.model_parameters_iterations == None: + if self.model_parameters_iterations is None: self.model_parameters_iterations = self.model.get_model_parameters()
None
の比較は、==
ではなく、 is
を使いましょう。