Skip to content

Commit

Permalink
Merge pull request #193 from nabenabe0928/add-seed-option-to-smac
Browse files Browse the repository at this point in the history
Add seed option to SMAC
  • Loading branch information
not522 authored Dec 4, 2024
2 parents 4842c9c + 2733097 commit 1ad5e19
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion package/samplers/smac_sampler/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class SMACSampler(optunahub.samplers.SimpleBaseSampler):
initial design.
This argument does not have to be precise, but it is better to be exact for better
performance.
seed:
Seed for random number generator.
If ``None`` is given, seed is generated randomly.
surrogate_model_type:
What model to use for the probabilistic model.
Either "gp" (Gaussian process), "gp_mcmc" (Gaussian process with MCMC), or "rf"
Expand Down Expand Up @@ -99,6 +102,7 @@ def __init__(
self,
search_space: dict[str, BaseDistribution],
n_trials: int = 100,
seed: int | None = None,
*,
surrogate_model_type: str = "rf",
acq_func_type: str = "ei_log",
Expand All @@ -113,7 +117,9 @@ def __init__(
) -> None:
super().__init__(search_space)
self._cs, self._hp_scale_value = self._convert_to_config_space_design_space(search_space)
scenario = Scenario(configspace=self._cs, deterministic=True, n_trials=n_trials)
scenario = Scenario(
configspace=self._cs, deterministic=True, n_trials=n_trials, seed=seed or -1
)
surrogate_model = self._get_surrogate_model(
scenario,
surrogate_model_type,
Expand Down

0 comments on commit 1ad5e19

Please sign in to comment.