PKU-DAIR / open-box

Generalized and Efficient Blackbox Optimization System
https://open-box.readthedocs.io
Other
356 stars 52 forks source link

'Sum' object has no attribute '_args_cache' #72

Closed Dalton2333 closed 4 months ago

Dalton2333 commented 8 months ago

I was using the Advisor() and get this error when calling advisor.get_suggestion()

Exception has occurred: AttributeError 'Sum' object has no attribute '_args_cache' File "E:...\surrogate\base\gp_kernels.py", line 132, in get_params args = self._args_cache File "E:...\surrogate\base\gp.py", line 128, in _train self.gp.fit(X, y) File "E:...\surrogate\base\base_model.py", line 137, in train return self._train(X, Y) File "E:...\core\generic_advisor.py", line 410, in get_suggestion self.surrogate_model.train(X, Y[:, 0]) File "E:...\pattern_curve_optimizer_v2_trial.py", line 557, in config = advisor.get_suggestion() AttributeError: 'Sum' object has no attribute '_args_cache'

The advisor was like: advisor = Advisor( config_space =config_space, num_objectives=1, optimization_strategy='bo', surrogate_type='gp', task_id="xxx", ) The config space has 60 parameters.

jhj0411jhj commented 7 months ago

I think the AttributeError should be caught. Please check if the code has been modified. https://github.com/PKU-DAIR/open-box/blob/77fe7e932f9eecec076c5db0610b20758a9926cc/openbox/surrogate/base/gp_kernels.py#L130-L132

Dalton2333 commented 7 months ago

Yes that's why it feels so strange. The code is not changed and the exception still raises. The same thing happens to: https://github.com/PKU-DAIR/open-box/blob/77fe7e932f9eecec076c5db0610b20758a9926cc/openbox/surrogate/base/gp_kernels.py#L150C1-L154C1

where the exception is: Exception has occurred: AttributeError 'ConstantKernel' object has no attribute '_hyperparameters_cache'

jhj0411jhj commented 7 months ago

Please provide the python version and openbox version (via pip list|grep openbox). Is openbox installed via PyPI or source code? Another strange thing is args = self._args_cache should be in line 131, not File "E:...\surrogate\base\gp_kernels.py", line 132.

Dalton2333 commented 7 months ago

I was using python 3.7.11 and openbox v0.8.1 in source code. I checked the code and it seems I added an empty line by mistake, all other lines are the same.

jhj0411jhj commented 7 months ago

Please try reinstalling openbox and see if the problem still exists.

jhj0411jhj commented 4 months ago

The issue will be closed. More details are needed to reproduce the bug. Please feel free to reopen it if you have further questions.