config_sampler¶
Classes
|
Optuna based sampler for greedy search over different configurations. |
- class ConfigSampler(configs: List[dict], random_generator: Optional[numpy.random._generator.Generator] = None, retries: int = 10)[source]¶
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.
- 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
- reseed_rng() None ¶
Reseed sampler’s random number generator.
This method is called by the
Study
instance if trials are executed in parallel with the optionn_jobs>1
. In that case, the sampler instance will be replicated including the state of the random number generator, and they may suggest the same values. To prevent this issue, this method assigns a different seed to each random number generator.- Return type
None
- 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