syne_tune.optimizer.schedulers.asha module
- class syne_tune.optimizer.schedulers.asha.AsynchronousSuccessiveHalving(config_space, metric, do_minimize=True, searcher='random_search', time_attr='training_iteration', max_t=100, grace_period=1, reduction_factor=3, brackets=1, random_seed=None, searcher_kwargs=None)[source]
Bases:
TrialSchedulerImplements Asynchronous Successive Halving. This code is adapted from the RayTune implementation.
References:
Massively Parallel Hyperparameter Tuning L. Li and K. Jamieson and A. Rostamizadeh and K. Gonina and M. Hardt and B. Recht and A. Talwalkar arXiv:1810.05934 [cs.LG]
- 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.do_minimize (
Optional[bool]) – If True, we minimize the objective function specified bymetric. Defaults to True.searcher (
Union[str,IndependentMultiFidelitySearcher,LastValueMultiFidelitySearcher,None]) – Searcher object to sample configurations.time_attr (
str) – A training result attr to use for comparing time. Note that you can pass in something non-temporal such astraining_iterationas a measure of progress, the only requirement is that the attribute should increase monotonically. Defaults to “training_iteration”max_t (
int) – max time units per trial. Trials will be stopped aftermax_ttime units (determined bytime_attr) have passed. Defaults to 100grace_period (
int) – Only stop trials at least this old in time. The units are the same as the attribute named bytime_attr. Defaults to 1reduction_factor (
float) – Used to set halving rate and amount. This is simply a unit-less scalar. Defaults to 3brackets (
int) – Number of brackets. Each bracket has a differentgrace_periodand number of rung levels. Defaults to 1random_seed (
Optional[int]) – Seed for initializing random number generators.searcher_kwargs (
Optional[dict]) – Additional keyword arguments for the searcher.
- 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_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
- on_trial_complete(trial, result)[source]
Notification for the completion of trial.
Note that
on_trial_result()is called with the same result before. However, if the scheduler only uses one final report from each trial, it may ignoreon_trial_result()and just useresulthere.- Parameters:
trial (
Trial) – Trial which is completingresult (
Dict[str,Any]) – Result dictionary
- on_trial_remove(trial)[source]
Called to remove trial.
This is called when the trial is in PAUSED or PENDING state. Otherwise, call
on_trial_complete().- Parameters:
trial (
Trial) – Trial to be removed
- class syne_tune.optimizer.schedulers.asha.Bracket(min_t, max_t, reduction_factor, s, priority=None)[source]
Bases:
objectBookkeeping system to track recorded values.
Rungs are created in reversed order so that we can more easily find the correct rung corresponding to the current iteration of the result.