-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for SMAC #206
base: main
Are you sure you want to change the base?
Add tests for SMAC #206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,6 +2,7 @@ | |||||
|
||||||
from collections.abc import Sequence | ||||||
from pathlib import Path | ||||||
import warnings | ||||||
|
||||||
from ConfigSpace import Categorical | ||||||
from ConfigSpace import Configuration | ||||||
|
@@ -226,6 +227,11 @@ def _get_init_design( | |||||
raise NotImplementedError(f"Unknown Initial Design Type: {init_design_type}") | ||||||
return init_design | ||||||
|
||||||
def reseed_rng(self) -> None: | ||||||
warnings.warn( | ||||||
"SMACSampler does not support reseeding the random number generator. Please instantiate a new SMACSampler with a different random seed instead." | ||||||
) | ||||||
|
||||||
def sample_relative( | ||||||
self, study: Study, trial: FrozenTrial, search_space: dict[str, BaseDistribution] | ||||||
) -> dict[str, float]: | ||||||
|
@@ -237,6 +243,9 @@ def sample_relative( | |||||
study._storage.set_trial_system_attr(trial._trial_id, _SMAC_SEED_KEY, trial_info.seed) | ||||||
params = {} | ||||||
for name, hp_value in cfg.items(): | ||||||
# SMAC uses np.int64 for integer parameters | ||||||
if isinstance(hp_value, np.int64): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
hp_value = hp_value.item() # Convert to Python int. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SMAC returns |
||||||
if name in self._hp_scale_value: | ||||||
hp_value = self._integer_to_step_hp( | ||||||
integer_value=hp_value, scale_info=self._hp_scale_value[name] | ||||||
|
@@ -344,5 +353,5 @@ def _convert_to_config_space_design_space( | |||||
else: | ||||||
raise NotImplementedError(f"Unknown Hyperparameter Type: {type(distribution)}") | ||||||
if hp is not None: | ||||||
config_space.add_hyperparameter(hp) | ||||||
config_space.add(hp) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
return config_space, scale_values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reseed_rng
is currently not implemented. This will cause unexpected behavior whenn_jobs > 1
.