You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ValueError Traceback (most recent call last)
Cell In[1], line 23
21 acq = optimizer.get_acquisition_function(scenario)
22 intensifier = optimizer.get_intensifier(scenario, max_config_calls=1)
---> 23 optimizer = optimizer(scenario, foobar, acquisition_function=acq,
24 intensifier=intensifier, overwrite=True)
File ~\anaconda3\envs\badass\lib\site-packages\smac\facade\abstract_facade.py:125, in AbstractFacade.__init__(self, scenario, target_function, model, acquisition_function, acquisition_maximizer, initial_design, random_design, intensifier, multi_objective_algorithm, runhistory_encoder, config_selector, logging_level, callbacks, overwrite, dask_client)
122 setup_logging(logging_level)
124 if model is None:
--> 125 model = self.get_model(scenario)
127 if acquisition_function is None:
128 acquisition_function = self.get_acquisition_function(scenario)
File ~\anaconda3\envs\badass\lib\site-packages\smac\facade\blackbox_facade.py:77, in BlackBoxFacade.get_model(scenario, model_type, kernel)
74 raise ValueError(f"The model_type `{model_type}` is not supported. Choose one of {', '.join(types)}")
76 if kernel is None:
---> 77 kernel = BlackBoxFacade.get_kernel(scenario=scenario)
79 if model_type is None or model_type == "vanilla":
80 return GaussianProcess(
81 configspace=scenario.configspace,
82 kernel=kernel,
83 normalize_y=True,
84 seed=scenario.seed,
85 )
File ~\anaconda3\envs\badass\lib\site-packages\smac\facade\blackbox_facade.py:135, in BlackBoxFacade.get_kernel(scenario)
133 exp_kernel, ham_kernel = 0.0, 0.0
134 if len(cont_dims) > 0:
--> 135 exp_kernel = MaternKernel(
136 np.ones([len(cont_dims)]),
137 [(np.exp(-6.754111155189306), np.exp(0.0858637988771976)) for _ in range(len(cont_dims))],
138 nu=2.5,
139 operate_on=cont_dims,
140 )
141 if len(cat_dims) > 0:
142 ham_kernel = HammingKernel(
143 np.ones([len(cat_dims)]),
144 [(np.exp(-6.754111155189306), np.exp(0.0858637988771976)) for _ in range(len(cat_dims))],
145 operate_on=cat_dims,
146 )
File ~\anaconda3\envs\badass\lib\site-packages\smac\model\gaussian_process\kernels\matern_kernel.py:30, in MaternKernel.__init__(self, length_scale, length_scale_bounds, nu, operate_on, has_conditions, prior)
21 def __init__(
22 self,
23 length_scale: float | tuple[float, ...] | np.ndarray = 1.0,
(...)
28 prior: AbstractPrior | None = None,
29 ) -> None:
---> 30 super().__init__(
31 operate_on=operate_on,
32 has_conditions=has_conditions,
33 prior=prior,
34 length_scale=length_scale,
35 length_scale_bounds=length_scale_bounds,
36 nu=nu,
37 )
File ~\anaconda3\envs\badass\lib\site-packages\smac\model\gaussian_process\kernels\base_kernels.py:56, in AbstractKernel.__init__(self, operate_on, has_conditions, prior, **kwargs)
54 self.has_conditions = has_conditions
55 self.prior = prior
---> 56 self._set_active_dims(operate_on)
58 # Since this class is a mixin, we just pass all the other parameters to the next class.
59 super().__init__(**kwargs)
File ~\anaconda3\envs\badass\lib\site-packages\smac\model\gaussian_process\kernels\base_kernels.py:258, in AbstractKernel._set_active_dims(self, operate_on)
255 raise TypeError("The argument `operate_on` needs to be of type np.ndarray but is %s" % type(operate_on))
257 if operate_on.dtype != int:
--> 258 raise ValueError("The dtype of argument `operate_on` needs to be int, but is %s" % operate_on.dtype)
260 self.operate_on = operate_on
261 self._len_active = len(operate_on)
ValueError: The dtype of argument `operate_on` needs to be int, but is int64
Versions
2.0.1
Fix
I'm currently working through the issue by changing smac\model\gaussian_process\kernels\base_kernels.py:258 from
if operate_on.dtype != int:
to
if not np.issubdtype(operate_on.dtype, np.integer):
This is a broader check against multiple integer types that should all theoretically work within the code base. If you want to prevent negative integers you can always use np.unsignedinteger instead or whatever best fits the ultimate use and possible error field.
The text was updated successfully, but these errors were encountered:
Description
I should be able to instantiate a BlackBoxFacade for use in optimization, but it fails on a toy example.
Steps/Code to Reproduce
Minimum example to reproduce:
Expected Results
It should work.
Actual Results
Versions
2.0.1
Fix
I'm currently working through the issue by changing smac\model\gaussian_process\kernels\base_kernels.py:258 from
to
This is a broader check against multiple integer types that should all theoretically work within the code base. If you want to prevent negative integers you can always use
np.unsignedinteger
instead or whatever best fits the ultimate use and possible error field.The text was updated successfully, but these errors were encountered: