syne_tune.optimizer.schedulers package
- class syne_tune.optimizer.schedulers.MedianStoppingRule(scheduler, resource_attr, running_average=True, metric=None, grace_time=1, grace_population=5, rank_cutoff=0.5, random_seed=None, do_minimize=True)[source]
Bases:
TrialSchedulerApplies median stopping rule in top of an existing scheduler.
If result at time-step ranks less than the cutoff of other results observed at this time-step, the trial is interrupted and otherwise, the wrapped scheduler is called to make the stopping decision.
Suggest decisions are left to the wrapped scheduler.
The mode of the wrapped scheduler is used.
Reference:
Google Vizier: A Service for Black-Box Optimization.Golovin et al. 2017.Proceedings of the 23rd ACM SIGKDD International Conference on KnowledgeDiscovery and Data Mining, August 2017Pages 1487–1495- Parameters:
scheduler (
TrialScheduler) – Scheduler to be called for trial suggestion or when median-stopping-rule decision is to continue.resource_attr (
str) – Key in the reported dictionary that accounts for the resource (e.g. epoch).running_average (
bool) – IfTrue, then uses the running average of observation instead of raw observations. Defaults toTruemetric (
Optional[str]) – Metric to be considered, defaults toscheduler.metricgrace_time (
Optional[int]) – Median stopping rule is only applied for results whoseresource_attrexceeds this amount. Defaults to 1grace_population (
int) – Median stopping rule when at leastgrace_populationhave been observed at a resource level. Defaults to 5rank_cutoff (
float) – Results whose quantiles are below this level are discarded. Defaults to 0.5 (median)random_seed (
Optional[int]) – Seed used to initialize the random number generators.do_minimize (
Optional[bool]) – True if we minimize the objective function
- suggest()[source]
Returns a suggestion for a new trial, or one to be resumed
This method returns
suggestionof typeTrialSuggestion(unless there is no config left to explore, and None is returned).If
suggestion.spawn_new_trial_idisTrue, a new trial is to be started with configsuggestion.config. Typically, this new trial is started from scratch. But ifsuggestion.checkpoint_trial_idis given, the trial is to be (warm)started from the checkpoint written for the trial with this ID. The new trial has IDtrial_id.If
suggestion.spawn_new_trial_idisFalse, an existing and currently paused trial is to be resumed, whose ID issuggestion.checkpoint_trial_id. If this trial has a checkpoint, we start from there. In this case,suggestion.configis optional. If not given (default), the config of the resumed trial does not change. Otherwise, its config is overwritten bysuggestion.config(seeHyperbandSchedulerwithtype="promotion"for an example why this can be useful).Apart from the HP config, additional fields can be appended to the dict, these are passed to the trial function as well.
- Return type:
Optional[TrialSuggestion]- Returns:
Suggestion for a trial to be started or to be resumed, see above. If no suggestion can be made, None is returned
- on_trial_result(trial, result)[source]
Called on each intermediate result reported by a trial.
At this point, the trial scheduler can make a decision by returning one of
SchedulerDecision.CONTINUE,SchedulerDecision.PAUSE, orSchedulerDecision.STOP. This will only be called when the trial is currently running.- Parameters:
trial (
Trial) – Trial for which results are reportedresult (
Dict) – Result dictionary
- Return type:
str- Returns:
Decision what to do with the trial
- class syne_tune.optimizer.schedulers.PopulationBasedTraining(config_space, metric, resource_attr, max_t=100, custom_explore_fn=None, do_minimize=True, random_seed=None, population_size=4, perturbation_interval=60, quantile_fraction=0.25, resample_probability=0.25, searcher_kwargs=None)[source]
Bases:
TrialSchedulerImplements the Population Based Training (PBT) algorithm. This is an adapted version of the Ray Tune implementation:
https://docs.ray.io/en/latest/tune/tutorials/tune-advanced-tutorial.html
PBT was originally presented in the following paper:
Population based training (PBT) maintains a population of models spread across an asynchronous set of workers and dynamically adjust their hyperparameters during training. Every time a worker reaches a user-defined milestone, it returns the performance of the currently evaluated network. If the network is within the top percentile of the population, the worker resumes its training until the next milestone. If not, PBT selects a model from the top percentile uniformly at random. The worker now continues with the latest checkpoint of this new model but mutates the hyperparameters.
The mutation happens as following. For each hyperparameter, we either resample its value uniformly at random, or otherwise increment (multiply by 1.2) or decrement (multiply by 0.8) the value (probability 0.5 each). For categorical hyperparameters, the value is always resampled uniformly.
- Parameters:
config_space (
Dict[str,Any]) – Configuration space for the evaluation function.metric (
str) – Name of metric to optimize, key in results obtained viaon_trial_result.resource_attr (
str) – Name of resource attribute in results obtained viaon_trial_result, defaults to “time_total_s”max_t (
int) – max time units per trial. Trials will be stopped aftermax_ttime units (determined bytime_attr) have passed. Defaults to 100custom_explore_fn (
Optional[Callable[[dict],dict]]) – Custom exploration function. This function is invoked asf(config)instead of the built-in perturbations, and should returnconfigupdated as needed. If this is given,resample_probabilityis not useddo_minimize (
Optional[bool]) – If True, we minimize the objective function specified bymetric. Defaults to True.random_seed (
Optional[int]) – Seed for initializing random number generators.population_size (
int) – Size of the population, defaults to 4perturbation_interval (
int) – Models will be considered for perturbation at this interval ofresource_attr. Note that perturbation incurs checkpoint overhead, so you shouldn’t set this to be too frequent. Defaults to 60quantile_fraction (
float) – Parameters are transferred from the topquantile_fractionfraction of trials to the bottomquantile_fractionfraction. Needs to be between 0 and 0.5. Setting it to 0 essentially implies doing no exploitation at all. Defaults to 0.25resample_probability (
float) – The probability of resampling from the original distribution when applying_explore(). If not resampled, the value will be perturbed by a factor of 1.2 or 0.8 if continuous, or changed to an adjacent value if discrete. Defaults to 0.25
- on_trial_add(trial)[source]
Called when a new trial is added to the trial runner.
Additions are normally triggered by
suggest.- Parameters:
trial (
Trial) – Trial to be added
- on_trial_result(trial, result)[source]
Called on each intermediate result reported by a trial.
At this point, the trial scheduler can make a decision by returning one of
SchedulerDecision.CONTINUE,SchedulerDecision.PAUSE, orSchedulerDecision.STOP. This will only be called when the trial is currently running.- Parameters:
trial (
Trial) – Trial for which results are reportedresult (
Dict[str,Any]) – Result dictionary
- Return type:
str- Returns:
Decision what to do with the trial
- suggest()[source]
Returns a suggestion for a new trial, or one to be resumed
This method returns
suggestionof typeTrialSuggestion(unless there is no config left to explore, and None is returned).If
suggestion.spawn_new_trial_idisTrue, a new trial is to be started with configsuggestion.config. Typically, this new trial is started from scratch. But ifsuggestion.checkpoint_trial_idis given, the trial is to be (warm)started from the checkpoint written for the trial with this ID. The new trial has IDtrial_id.If
suggestion.spawn_new_trial_idisFalse, an existing and currently paused trial is to be resumed, whose ID issuggestion.checkpoint_trial_id. If this trial has a checkpoint, we start from there. In this case,suggestion.configis optional. If not given (default), the config of the resumed trial does not change. Otherwise, its config is overwritten bysuggestion.config(seeHyperbandSchedulerwithtype="promotion"for an example why this can be useful).Apart from the HP config, additional fields can be appended to the dict, these are passed to the trial function as well.
- Return type:
Optional[TrialSuggestion]- Returns:
Suggestion for a trial to be started or to be resumed, see above. If no suggestion can be made, None is returned
Subpackages
- syne_tune.optimizer.schedulers.multiobjective package
MultiObjectiveRegularizedEvolution- Submodules
- syne_tune.optimizer.schedulers.multiobjective.expected_hyper_volume_improvement module
- syne_tune.optimizer.schedulers.multiobjective.moasha module
- syne_tune.optimizer.schedulers.multiobjective.multi_objective_regularized_evolution module
- syne_tune.optimizer.schedulers.multiobjective.multi_surrogate_multi_objective_searcher module
- syne_tune.optimizer.schedulers.multiobjective.multiobjective_priority module
- syne_tune.optimizer.schedulers.multiobjective.non_dominated_priority module
- syne_tune.optimizer.schedulers.multiobjective.utils module
- syne_tune.optimizer.schedulers.searchers package
- Subpackages
- syne_tune.optimizer.schedulers.searchers.bayesopt package
- syne_tune.optimizer.schedulers.searchers.bore package
- syne_tune.optimizer.schedulers.searchers.botorch package
- syne_tune.optimizer.schedulers.searchers.conformal package
- syne_tune.optimizer.schedulers.searchers.kde package
- syne_tune.optimizer.schedulers.searchers.utils package
- Submodules
- syne_tune.optimizer.schedulers.searchers.last_value_multi_fidelity_searcher module
- syne_tune.optimizer.schedulers.searchers.multi_fidelity_searcher module
- syne_tune.optimizer.schedulers.searchers.random_searcher module
- syne_tune.optimizer.schedulers.searchers.regularized_evolution module
- syne_tune.optimizer.schedulers.searchers.searcher module
- syne_tune.optimizer.schedulers.searchers.searcher_factory module
- syne_tune.optimizer.schedulers.searchers.single_objective_searcher module
- Subpackages
- syne_tune.optimizer.schedulers.transfer_learning package
LegacyTransferLearningTaskEvaluationsLegacyTransferLearningTaskEvaluations.configuration_spaceLegacyTransferLearningTaskEvaluations.hyperparametersLegacyTransferLearningTaskEvaluations.objectives_namesLegacyTransferLearningTaskEvaluations.objectives_evaluationsLegacyTransferLearningTaskEvaluations.objective_values()LegacyTransferLearningTaskEvaluations.objective_index()LegacyTransferLearningTaskEvaluations.top_k_hyperparameter_configurations()
LegacyTransferLearningMixin- Subpackages
- Submodules
- syne_tune.optimizer.schedulers.transfer_learning.bounding_box module
- syne_tune.optimizer.schedulers.transfer_learning.transfer_learning_mixin module
- syne_tune.optimizer.schedulers.transfer_learning.transfer_learning_task_evaluation module
- syne_tune.optimizer.schedulers.transfer_learning.zero_shot module
- syne_tune.optimizer.schedulers.utils package
Submodules
- syne_tune.optimizer.schedulers.asha module
AsynchronousSuccessiveHalvingAsynchronousSuccessiveHalving.suggest()AsynchronousSuccessiveHalving.on_trial_add()AsynchronousSuccessiveHalving.on_trial_error()AsynchronousSuccessiveHalving.on_trial_result()AsynchronousSuccessiveHalving.on_trial_complete()AsynchronousSuccessiveHalving.on_trial_remove()AsynchronousSuccessiveHalving.metric_names()AsynchronousSuccessiveHalving.metric_mode()AsynchronousSuccessiveHalving.metadata()
Bracket
- syne_tune.optimizer.schedulers.ask_tell_scheduler module
- syne_tune.optimizer.schedulers.median_stopping_rule module
- syne_tune.optimizer.schedulers.multi_fidelity module
- syne_tune.optimizer.schedulers.pbt module
- syne_tune.optimizer.schedulers.random_seeds module
- syne_tune.optimizer.schedulers.remove_checkpoints module
- syne_tune.optimizer.schedulers.single_fidelity_scheduler module
- syne_tune.optimizer.schedulers.single_objective_scheduler module
- syne_tune.optimizer.schedulers.smac_scheduler module