ConfigSampler¶
- class ConfigSampler(configs: List[dict], random_generator: Optional[numpy.random._generator.Generator] = None, retries: int = 10)[source]¶
Bases:
optuna.samplers._base.BaseSampler
Optuna based sampler for greedy search over different configurations.
Init Config sampler.
- Parameters
configs (List[dict]) – pool of configs to sample from
random_generator (Optional[numpy.random._generator.Generator]) – numpy generator to get reproducible samples
retries (int) – number of retries to get new sample from storage. It could be useful if storage is not reliable.
- Inherited-members
Methods
after_trial
(study, trial, *args, **kwargs)Stop study if all configs have been tested.
get_config_by_hash
(hash)Get config by hash.
infer_relative_search_space
(*args, **kwargs)Infer relative search space.
reseed_rng
()Reseed sampler's random number generator.
sample_independent
(*args, **kwargs)Sample independent.
sample_relative
(study, trial, *args, **kwargs)Sample configuration to test.
Attributes
rng
- after_trial(study: optuna.study.study.Study, trial: optuna.trial._frozen.FrozenTrial, *args, **kwargs) None [source]¶
Stop study if all configs have been tested.
- Parameters
study (optuna.study.study.Study) – current optuna study
trial (optuna.trial._frozen.FrozenTrial) –
- Return type
None
- get_config_by_hash(hash: str)[source]¶
Get config by hash.
- Parameters
hash (str) – hash to get config for
- sample_relative(study: optuna.study.study.Study, trial: optuna.trial._frozen.FrozenTrial, *args, **kwargs) dict [source]¶
Sample configuration to test.
- Parameters
study (optuna.study.study.Study) – current optuna study
trial (optuna.trial._frozen.FrozenTrial) – optuna trial to use
- Returns
sampled configuration to run objective on
- Return type
dict