syne_tune.optimizer.schedulers.searchers package
- class syne_tune.optimizer.schedulers.searchers.BaseSearcher(config_space, metric, points_to_evaluate=None, mode='min')[source]
Bases:
object
Base class of searchers, which are components of schedulers responsible for implementing
get_config()
.Note
This is an abstract base class. In order to implement a new searcher, try to start from
StochasticAndFilterDuplicatesSearcher
orStochasticSearcher
, which implement generally useful properties.- Parameters:
config_space (
Dict
[str
,Any
]) – Configuration spacemetric (
Union
[List
[str
],str
]) –Name of metric passed to
update()
. Can be obtained from scheduler inconfigure_scheduler()
. In the case of multi-objective optimization,metric is a list of strings specifying all objectives to be optimized.
points_to_evaluate (
Optional
[List
[Dict
[str
,Any
]]]) – List of configurations to be evaluated initially (in that order). Each config in the list can be partially specified, or even be an empty dict. For each hyperparameter not specified, the default value is determined using a midpoint heuristic. IfNone
(default), this is mapped to[dict()]
, a single default config determined by the midpoint heuristic. If[]
(empty list), no initial configurations are specified.mode (
Union
[List
[str
],str
]) – Should metric be minimized (“min”, default) or maximized (“max”). In the case of multi-objective optimization, mode can be a list defining for each metric if it is minimized or maximized
- configure_scheduler(scheduler)[source]
Some searchers need to obtain information from the scheduler they are used with, in order to configure themselves. This method has to be called before the searcher can be used.
- Parameters:
scheduler (
TrialScheduler
) – Scheduler the searcher is used with.
- get_config(**kwargs)[source]
Suggest a new configuration.
Note: Query
_next_initial_config()
for initial configs to return first.- Parameters:
kwargs – Extra information may be passed from scheduler to searcher
- Return type:
Optional
[Dict
[str
,Any
]]- Returns:
New configuration. The searcher may return None if a new configuration cannot be suggested. In this case, the tuning will stop. This happens if searchers never suggest the same config more than once, and all configs in the (finite) search space are exhausted.
- on_trial_result(trial_id, config, result, update)[source]
Inform searcher about result
The scheduler passes every result. If
update == True
, the searcher should update its surrogate model (if any), otherwiseresult
is an intermediate result not modelled.The default implementation calls
_update()
ifupdate == True
. It can be overwritten by searchers which also react to intermediate results.- Parameters:
trial_id (
str
) – Seeon_trial_result()
config (
Dict
[str
,Any
]) – Seeon_trial_result()
result (
Dict
[str
,Any
]) – Seeon_trial_result()
update (
bool
) – Should surrogate model be updated?
- register_pending(trial_id, config=None, milestone=None)[source]
Signals to searcher that evaluation for trial has started, but not yet finished, which allows model-based searchers to register this evaluation as pending.
- Parameters:
trial_id (
str
) – ID of trial to be registered as pending evaluationconfig (
Optional
[Dict
[str
,Any
]]) – Iftrial_id
has not been registered with the searcher, its configuration must be passed here. Ignored otherwise.milestone (
Optional
[int
]) – For multi-fidelity schedulers, this is the next rung level the evaluation will attend, so that model registers(config, milestone)
as pending.
- remove_case(trial_id, **kwargs)[source]
Remove data case previously appended by
_update()
For searchers which maintain the dataset of all cases (reports) passed to update, this method allows to remove one case from the dataset.
- Parameters:
trial_id (
str
) – ID of trial whose data is to be removedkwargs – Extra arguments, optional
- evaluation_failed(trial_id)[source]
Called by scheduler if an evaluation job for a trial failed.
The searcher should react appropriately (e.g., remove pending evaluations for this trial, not suggest the configuration again).
- Parameters:
trial_id (
str
) – ID of trial whose evaluated failed
- cleanup_pending(trial_id)[source]
Removes all pending evaluations for trial
trial_id
.This should be called after an evaluation terminates. For various reasons (e.g., termination due to convergence), pending candidates for this evaluation may still be present.
- Parameters:
trial_id (
str
) – ID of trial whose pending evaluations should be cleared
- dataset_size()[source]
- Returns:
Size of dataset a model is fitted to, or 0 if no model is fitted to data
- model_parameters()[source]
- Returns:
Dictionary with current model (hyper)parameter values if this is supported; otherwise empty
- get_state()[source]
Together with
clone_from_state()
, this is needed in order to store and re-create the mutable state of the searcher. The state returned here must be pickle-able.- Return type:
Dict
[str
,Any
]- Returns:
Pickle-able mutable state of searcher
- clone_from_state(state)[source]
Together with
get_state()
, this is needed in order to store and re-create the mutable state of the searcher.Given state as returned by
get_state()
, this method combines the non-pickle-able part of the immutable state from self with state and returns the corresponding searcher clone. Afterwards,self
is not used anymore.- Parameters:
state (
Dict
[str
,Any
]) – See above- Returns:
New searcher object
- property debug_log: DebugLogPrinter | None
Some subclasses support writing a debug log, using
DebugLogPrinter
. SeeRandomSearcher
for an example.- Returns:
debug_log
object`` or None (not supported)
- syne_tune.optimizer.schedulers.searchers.impute_points_to_evaluate(points_to_evaluate, config_space)[source]
Transforms
points_to_evaluate
argument toBaseSearcher
. Each config in the list can be partially specified, or even be an empty dict. For each hyperparameter not specified, the default value is determined using a midpoint heuristic. Also, duplicate entries are filtered out. If None (default), this is mapped to[dict()]
, a single default config determined by the midpoint heuristic. If[]
(empty list), no initial configurations are specified.- Parameters:
points_to_evaluate (
Optional
[List
[Dict
[str
,Any
]]]) – Argument toBaseSearcher
config_space (
Dict
[str
,Any
]) – Configuration space
- Return type:
List
[Dict
[str
,Any
]]- Returns:
List of fully specified initial configs
- class syne_tune.optimizer.schedulers.searchers.StochasticSearcher(config_space, metric, points_to_evaluate=None, **kwargs)[source]
Bases:
BaseSearcher
Base class of searchers which use random decisions. Creates the
random_state
member, which must be used for all random draws.Making proper use of this interface allows us to run experiments with control of random seeds, e.g. for paired comparisons or integration testing.
Additional arguments on top of parent class
BaseSearcher
:- Parameters:
random_seed_generator (
RandomSeedGenerator
, optional) – If given, random seed is drawn from thererandom_seed (int, optional) – Used if
random_seed_generator
is not given.
- class syne_tune.optimizer.schedulers.searchers.StochasticAndFilterDuplicatesSearcher(config_space, metric, points_to_evaluate=None, allow_duplicates=None, restrict_configurations=None, **kwargs)[source]
Bases:
StochasticSearcher
Base class for searchers with the following properties:
Random decisions use common
random_state
Maintains exclusion list to filter out duplicates in
get_config()
ifallows_duplicates == False`. If this is ``True
, duplicates are not filtered, and the exclusion list is used only to avoid configurations of failed trials.If
restrict_configurations
is given, this is a list of configurations, and the searcher only suggests configurations from there. Ifallow_duplicates == False
, entries are popped off this list once suggested.points_to_evaluate
is filtered to only contain entries in this set.
In order to make use of these features:
Reject configurations in
get_config()
ifshould_not_suggest()
returnsTrue
. If the configuration is drawn at random, use_get_random_config()
, which incorporates this filteringImplement
_get_config()
instead ofget_config()
. The latter adds the new config to the exclusion list ifallow_duplicates == False
Note: Not all searchers which filter duplicates make use of this class.
Additional arguments on top of parent class
StochasticSearcher
:- Parameters:
allow_duplicates (
Optional
[bool
]) – See above. Defaults toFalse
restrict_configurations (
Optional
[List
[Dict
[str
,Any
]]]) – See above, optional
- property allow_duplicates: bool
- should_not_suggest(config)[source]
- Parameters:
config (
Dict
[str
,Any
]) – Configuration- Return type:
bool
- Returns:
get_config()
should not suggest this configuration?
- get_config(**kwargs)[source]
Suggest a new configuration.
Note: Query
_next_initial_config()
for initial configs to return first.- Parameters:
kwargs – Extra information may be passed from scheduler to searcher
- Return type:
Optional
[Dict
[str
,Any
]]- Returns:
New configuration. The searcher may return None if a new configuration cannot be suggested. In this case, the tuning will stop. This happens if searchers never suggest the same config more than once, and all configs in the (finite) search space are exhausted.
- register_pending(trial_id, config=None, milestone=None)[source]
Signals to searcher that evaluation for trial has started, but not yet finished, which allows model-based searchers to register this evaluation as pending.
- Parameters:
trial_id (
str
) – ID of trial to be registered as pending evaluationconfig (
Optional
[Dict
[str
,Any
]]) – Iftrial_id
has not been registered with the searcher, its configuration must be passed here. Ignored otherwise.milestone (
Optional
[int
]) – For multi-fidelity schedulers, this is the next rung level the evaluation will attend, so that model registers(config, milestone)
as pending.
- syne_tune.optimizer.schedulers.searchers.extract_random_seed(**kwargs)[source]
- Return type:
(
int
,Dict
[str
,Any
])
- class syne_tune.optimizer.schedulers.searchers.RandomSearcher(config_space, metric, points_to_evaluate=None, debug_log=False, resource_attr=None, allow_duplicates=None, restrict_configurations=None, **kwargs)[source]
Bases:
StochasticAndFilterDuplicatesSearcher
Searcher which randomly samples configurations to try next.
Additional arguments on top of parent class
StochasticAndFilterDuplicatesSearcher
:- Parameters:
debug_log (
Union
[bool
,DebugLogPrinter
]) – IfTrue
, debug log printing is activated. Logs which configs are chosen when, and which metric values are obtained. Defaults toFalse
resource_attr (
Optional
[str
]) – Optional. Key inresult
passed to_update()
for resource value (for multi-fidelity schedulers)
- configure_scheduler(scheduler)[source]
Some searchers need to obtain information from the scheduler they are used with, in order to configure themselves. This method has to be called before the searcher can be used.
- Parameters:
scheduler (
TrialScheduler
) – Scheduler the searcher is used with.
- clone_from_state(state)[source]
Together with
get_state()
, this is needed in order to store and re-create the mutable state of the searcher.Given state as returned by
get_state()
, this method combines the non-pickle-able part of the immutable state from self with state and returns the corresponding searcher clone. Afterwards,self
is not used anymore.- Parameters:
state (
Dict
[str
,Any
]) – See above- Returns:
New searcher object
- property debug_log
Some subclasses support writing a debug log, using
DebugLogPrinter
. SeeRandomSearcher
for an example.- Returns:
debug_log
object`` or None (not supported)
- class syne_tune.optimizer.schedulers.searchers.GridSearcher(config_space, metric, points_to_evaluate=None, num_samples=None, shuffle_config=True, allow_duplicates=False, **kwargs)[source]
Bases:
StochasticSearcher
Searcher that samples configurations from an equally spaced grid over config_space.
It first evaluates configurations defined in points_to_evaluate and then continues with the remaining points from the grid.
Additional arguments on top of parent class
StochasticSearcher
.- Parameters:
num_samples (
Optional
[Dict
[str
,int
]]) – Dictionary, optional. Number of samples per hyperparameter. This is required for hyperparameters of type float, optional for integer hyperparameters, and will be ignored for other types (categorical, scalar). If left unspecified, a default value ofDEFAULT_NSAMPLE
will be used for float parameters, and the smallest ofDEFAULT_NSAMPLE
and integer range will be used for integer parameters.shuffle_config (
bool
) – IfTrue
(default), the order of configurations suggested after those specified inpoints_to_evaluate
is shuffled. Otherwise, the order will follow the Cartesian product of the configurations.allow_duplicates (
bool
) – IfTrue
,get_config()
may return the same configuration more than once. Defaults toFalse
- get_config(**kwargs)[source]
Select the next configuration from the grid.
This is done without replacement, so previously returned configs are not suggested again.
- Return type:
Optional
[dict
]- Returns:
A new configuration that is valid, or None if no new config can be suggested. The returned configuration is a dictionary that maps hyperparameters to its values.
- get_state()[source]
Together with
clone_from_state()
, this is needed in order to store and re-create the mutable state of the searcher. The state returned here must be pickle-able.- Return type:
Dict
[str
,Any
]- Returns:
Pickle-able mutable state of searcher
- clone_from_state(state)[source]
Together with
get_state()
, this is needed in order to store and re-create the mutable state of the searcher.Given state as returned by
get_state()
, this method combines the non-pickle-able part of the immutable state from self with state and returns the corresponding searcher clone. Afterwards,self
is not used anymore.- Parameters:
state (
Dict
[str
,Any
]) – See above- Returns:
New searcher object
- syne_tune.optimizer.schedulers.searchers.searcher_factory(searcher_name, **kwargs)[source]
Factory for searcher objects
This function creates searcher objects from string argument name and additional kwargs. It is typically called in the constructor of a scheduler (see
FIFOScheduler
), which provides most of the requiredkwargs
.- Parameters:
searcher_name (
str
) – Value ofsearcher
argument to scheduler (seeFIFOScheduler
)kwargs – Argument to
BaseSearcher
constructor
- Return type:
- Returns:
New searcher object
- class syne_tune.optimizer.schedulers.searchers.ModelBasedSearcher(config_space, metric, points_to_evaluate=None, **kwargs)[source]
Bases:
StochasticSearcher
Common code for surrogate model based searchers
If
num_initial_random_choices > 0
, initial configurations are drawn using an internalRandomSearcher
object, which is created in_assign_random_searcher()
. This internal random searcher sharesrandom_state
with the searcher here. This ensures that ifModelBasedSearcher
andRandomSearcher
objects are created with the samerandom_seed
andpoints_to_evaluate
argument, initial configurations are identical until_get_config_modelbased()
kicks in.Note that this works because
random_state
is only used in the internal random searcher until meth:_get_config_modelbased
is first called.- on_trial_result(trial_id, config, result, update)[source]
Inform searcher about result
The scheduler passes every result. If
update == True
, the searcher should update its surrogate model (if any), otherwiseresult
is an intermediate result not modelled.The default implementation calls
_update()
ifupdate == True
. It can be overwritten by searchers which also react to intermediate results.- Parameters:
trial_id (
str
) – Seeon_trial_result()
config (
Dict
[str
,Any
]) – Seeon_trial_result()
result (
Dict
[str
,Any
]) – Seeon_trial_result()
update (
bool
) – Should surrogate model be updated?
- get_config(**kwargs)[source]
Runs Bayesian optimization in order to suggest the next config to evaluate.
- Return type:
Optional
[Dict
[str
,Any
]]- Returns:
Next config to evaluate at
- dataset_size()[source]
- Returns:
Size of dataset a model is fitted to, or 0 if no model is fitted to data
- model_parameters()[source]
- Returns:
Dictionary with current model (hyper)parameter values if this is supported; otherwise empty
- get_state()[source]
The mutable state consists of the GP model parameters, the
TuningJobState
, and theskip_optimization
predicate (which can have a mutable state). We assume thatskip_optimization
can be pickled.Note that we do not have to store the state of
_random_searcher
, since this internal searcher shares itsrandom_state
with the searcher here.- Return type:
Dict
[str
,Any
]
- property debug_log
Some subclasses support writing a debug log, using
DebugLogPrinter
. SeeRandomSearcher
for an example.- Returns:
debug_log
object`` or None (not supported)
- class syne_tune.optimizer.schedulers.searchers.BayesianOptimizationSearcher(config_space, metric, points_to_evaluate=None, **kwargs)[source]
Bases:
ModelBasedSearcher
Common Code for searchers using Bayesian optimization
We implement Bayesian optimization, based on a model factory which parameterizes the state transformer. This implementation works with any type of surrogate model and acquisition function, which are compatible with each other.
The following happens in
get_config()
:For the first
num_init_random
calls, a config is drawn at random (afterpoints_to_evaluate
, which are included in thenum_init_random
initial ones). Afterwards, Bayesian optimization is used, unless there are no finished evaluations yet (a surrogate model cannot be used with no data at all)For BO, model hyperparameter are refit first. This step can be skipped (see
opt_skip_*
parameters).Next, the BO decision is made based on
BayesianOptimizationAlgorithm
. This involves samplingnum_init_candidates`
configs are sampled at random, ranking them with a scoring function (initial_scoring
), and finally runing local optimization starting from the top scoring config.
- configure_scheduler(scheduler)[source]
Some searchers need to obtain information from the scheduler they are used with, in order to configure themselves. This method has to be called before the searcher can be used.
- Parameters:
scheduler (
TrialScheduler
) – Scheduler the searcher is used with.
- register_pending(trial_id, config=None, milestone=None)[source]
Registers trial as pending. This means the corresponding evaluation task is running. Once it finishes, update is called for this trial.
- get_batch_configs(batch_size, num_init_candidates_for_batch=None, **kwargs)[source]
Asks for a batch of
batch_size
configurations to be suggested. This is roughly equivalent to callingget_config
batch_size
times, marking the suggested configs as pending in the state (but the state is not modified here). This means the batch is chosen sequentially, at about the cost of callingget_config
batch_size
times.If
num_init_candidates_for_batch
is given, it is used instead ofnum_init_candidates
for the selection of all but the first config in the batch. In order to speed up batch selection, choosenum_init_candidates_for_batch
smaller thannum_init_candidates
.If less than
batch_size
configs are returned, the search space has been exhausted.Note: Batch selection does not support
debug_log
right now: make sure to switch this off when creating scheduler and searcher.- Return type:
List
[Dict
[str
,Union
[int
,float
,str
]]]
- class syne_tune.optimizer.schedulers.searchers.GPFIFOSearcher(config_space, metric, points_to_evaluate=None, clone_from_state=False, **kwargs)[source]
Bases:
BayesianOptimizationSearcher
Gaussian process Bayesian optimization for FIFO scheduler
This searcher must be used with
FIFOScheduler
. It provides Bayesian optimization, based on a Gaussian process surrogate model.It is not recommended creating
GPFIFOSearcher
searcher objects directly, but rather to createFIFOScheduler
objects withsearcher="bayesopt"
, and passing arguments here insearch_options
. This will use the appropriate functions from :mod:syne_tune.optimizer.schedulers.searchers.gp_searcher_factory
to create components in a consistent way.Most of the implementation is generic in
BayesianOptimizationSearcher
.Note: If metric values are to be maximized (
mode-"max"
in scheduler), the searcher usesmap_reward
to map metric values to internal criterion values, and minimizes the latter. The default choice is to multiply values by -1.Pending configurations (for which evaluation tasks are currently running) are dealt with by fantasizing (i.e., target values are drawn from the current posterior, and acquisition functions are averaged over this sample, see
num_fantasy_samples
).The GP surrogate model uses a Matern 5/2 covariance function with automatic relevance determination (ARD) of input attributes, and a constant mean function. The acquisition function is expected improvement (EI). All hyperparameters of the surrogate model are estimated by empirical Bayes (maximizing the marginal likelihood). In general, this hyperparameter fitting is the most expensive part of a
get_config()
call.Note that the full logic of construction based on arguments is given in :mod:
syne_tune.optimizer.schedulers.searchers.gp_searcher_factory
. In particular, seegp_fifo_searcher_defaults()
for default values.Additional arguments on top of parent class
StochasticSearcher
:- Parameters:
clone_from_state (bool) – Internal argument, do not use
resource_attr (str, optional) – Name of resource attribute in reports. This is optional here, but required for multi-fidelity searchers. If
resource_attr
andcost_attr
are given, cost values are read from each report and stored in the state. This allows cost models to be fit on more data.cost_attr (str, optional) – Name of cost attribute in data obtained from reporter (e.g., elapsed training time). Needed only by cost-aware searchers. Depending on whether
resource_attr
is given, cost values are read from each report or only at the end.num_init_random (int, optional) – Number of initial
get_config()
calls for which randomly sampled configs are returned. Afterwards, the model-based searcher is used. Defaults toDEFAULT_NUM_INITIAL_RANDOM_EVALUATIONS
num_init_candidates (int, optional) – Number of initial candidates sampled at random in order to seed the model-based search in
get_config
. Defaults toDEFAULT_NUM_INITIAL_CANDIDATES
num_fantasy_samples (int, optional) – Number of samples drawn for fantasizing (latent target values for pending evaluations), defaults to 20
no_fantasizing (bool, optional) – If True, fantasizing is not done and pending evaluations are ignored. This may lead to loss of diversity in decisions. Defaults to
False
input_warping (bool, optional) – If
True
, we use a warping transform, so the kernel function becomes \(k(w(x), w(x'))\), where \(w(x)\) is a warping transform parameterized by two non-negative numbers per component, which are learned as hyperparameters. See alsoWarping
. Coordinates which belong to categorical hyperparameters, are not warped. Defaults toFalse
.boxcox_transform (bool, optional) – If
True
, target values are transformed before being fitted with a Gaussian marginal likelihood. This is using the Box-Cox transform with a parameter \(\lambda\), which is learned alongside other parameters of the surrogate model. The transform is \(\log y\) for \(\lambda = 0\), and \(y - 1\) for \(\lambda = 1\). This option requires the targets to be positive. Defaults toFalse
.gp_base_kernel (str, optional) – Selects the covariance (or kernel) function to be used. Supported choices are
SUPPORTED_BASE_MODELS
. Defaults to “matern52-ard” (Matern 5/2 with automatic relevance determination).acq_function (str, optional) – Selects the acquisition function to be used. Supported choices are
SUPPORTED_ACQUISITION_FUNCTIONS
. Defaults to “ei” (expected improvement acquisition function).acq_function_kwargs (dict, optional) – Some acquisition functions have additional parameters, they can be passed here. If none are given, default values are used.
initial_scoring (str, optional) –
Scoring function to rank initial candidates (local optimization of EI is started from top scorer):
”thompson_indep”: Independent Thompson sampling; randomized score, which can increase exploration
”acq_func”: score is the same (EI) acquisition function which is used for local optimization afterwards
Defaults to
DEFAULT_INITIAL_SCORING
skip_local_optimization (bool, optional) – If
True
, the local gradient-based optimization of the acquisition function is skipped, and the top-ranked initial candidate (after initial scoring) is returned instead. In this case,initial_scoring="acq_func"
makes most sense, otherwise the acquisition function will not be used. Defaults to Falseopt_nstarts (int, optional) – Parameter for surrogate model fitting. Number of random restarts. Defaults to 2
opt_maxiter (int, optional) – Parameter for surrogate model fitting. Maximum number of iterations per restart. Defaults to 50
opt_warmstart (bool, optional) – Parameter for surrogate model fitting. If
True
, each fitting is started from the previous optimum. Not recommended in general. Defaults toFalse
opt_verbose (bool, optional) – Parameter for surrogate model fitting. If
True
, lots of output. Defaults toFalse
max_size_data_for_model (int, optional) – If this is set, we limit the number of observations the surrogate model is fitted on this value. If there are more observations, they are down sampled, see
SubsampleSingleFidelityStateConverter
for details. This down sampling is repeated every time the model is fit. Theopt_skip_*
predicates are evaluated before the state is downsampled. PassNone
not to apply such a threshold. The default isDEFAULT_MAX_SIZE_DATA_FOR_MODEL
.max_size_top_fraction (float, optional) – Only used if
max_size_data_for_model
is set. This fraction of the down sampled set is filled with the top entries in the full set, the remaining ones are sampled at random from the full set, seeSubsampleSingleFidelityStateConverter
for details. Defaults to 0.25.opt_skip_init_length (int, optional) – Parameter for surrogate model fitting, skip predicate. Fitting is never skipped as long as number of observations below this threshold. Defaults to 150
opt_skip_period (int, optional) – Parameter for surrogate model fitting, skip predicate. If
>1
, and number of observations aboveopt_skip_init_length
, fitting is done only K-th call, and skipped otherwise. Defaults to 1 (no skipping)allow_duplicates (bool, optional) – If
True
,get_config()
may return the same configuration more than once. Defaults toFalse
restrict_configurations (List[dict], optional) – If given, the searcher only suggests configurations from this list. This needs
skip_local_optimization == True
. Ifallow_duplicates == False
, entries are popped off this list once suggested.map_reward (str or
MapReward
, optional) –In the scheduler, the metric may be minimized or maximized, but internally, Bayesian optimization is minimizing the criterion.
map_reward
converts from metric to internal criterion:”minus_x”:
criterion = -metric
”<a>_minus_x”:
criterion = <a> - metric
. For example “1_minus_x” maps accuracy to zero-one error
From a technical standpoint, it does not matter what is chosen here, because criterion is only used internally. Also note that criterion data is always normalized to mean 0, variance 1 before fitted with a Gaussian process. Defaults to “1_minus_x”
transfer_learning_task_attr (str, optional) – Used to support transfer HPO, where the state contains observed data from several tasks, one of which is the active one. To this end,
config_space
must contain a categorical parameter of nametransfer_learning_task_attr
, whose range are all task IDs. Also,transfer_learning_active_task
must denote the active task, andtransfer_learning_active_config_space
is used asactive_config_space
argument inHyperparameterRanges
. This allows us to use a narrower search space for the active task than for the union of all tasks (config_space
must be that), which is needed if some configurations of non-active tasks lie outside of the ranges inactive_config_space
. One of the implications is thatfilter_observed_data()
is selecting configs of the active task, so that incumbents or exclusion lists are restricted to data from the active task.transfer_learning_active_task (str, optional) – See
transfer_learning_task_attr
.transfer_learning_active_config_space (Dict[str, Any], optional) – See
transfer_learning_task_attr
. If not given,config_space
is the search space for the active task as well. This active config space need not contain thetransfer_learning_task_attr
parameter. In fact, this parameter is set to a categorical withtransfer_learning_active_task
as single value, so that new configs are chosen for the active task only.transfer_learning_model (str, optional) –
See
transfer_learning_task_attr
. Specifies the surrogate model to be used for transfer learning:”matern52_product”: Kernel is product of Matern 5/2 (not ARD) on
transfer_learning_task_attr
and Matern 5/2 (ARD) on the rest. Assumes that data from same task are more closely related than data from different tasks”matern52_same”: Kernel is Matern 5/2 (ARD) on the rest of the variables,
transfer_learning_task_attr
is ignored. Assumes that data from all tasks can be merged together
Defaults to “matern52_product”
- clone_from_state(state)[source]
Together with
get_state()
, this is needed in order to store and re-create the mutable state of the searcher.Given state as returned by
get_state()
, this method combines the non-pickle-able part of the immutable state from self with state and returns the corresponding searcher clone. Afterwards,self
is not used anymore.- Parameters:
state – See above
- Returns:
New searcher object
- class syne_tune.optimizer.schedulers.searchers.GPMultiFidelitySearcher(config_space, metric, points_to_evaluate=None, **kwargs)[source]
Bases:
GPFIFOSearcher
Gaussian process Bayesian optimization for asynchronous Hyperband scheduler.
This searcher must be used with a scheduler of type
MultiFidelitySchedulerMixin
. It provides a novel combination of Bayesian optimization, based on a Gaussian process surrogate model, with Hyperband scheduling. In particular, observations across resource levels are modelled jointly.It is not recommended to create
GPMultiFidelitySearcher
searcher objects directly, but rather to createHyperbandScheduler
objects withsearcher="bayesopt"
, and passing arguments here insearch_options
. This will use the appropriate functions from :mod:syne_tune.optimizer.schedulers.searchers.gp_searcher_factory
to create components in a consistent way.Most of
GPFIFOSearcher
comments apply here as well. In multi-fidelity HPO, we optimize a function \(f(\mathbf{x}, r)\), \(\mathbf{x}\) the configuration, \(r\) the resource (or time) attribute. The latter must be a positive integer. In most applications,resource_attr == "epoch"
, and the resource is the number of epochs already trained.If
model == "gp_multitask"
(default), we model the function \(f(\mathbf{x}, r)\) jointly over all resource levels \(r\) at which it is observed (but seesearcher_data
inHyperbandScheduler
). The kernel and mean function of our surrogate model are over \((\mathbf{x}, r)\). The surrogate model is selected bygp_resource_kernel
. More details about the supported kernels is in:Tiao, Klein, Lienart, Archambeau, Seeger (2020)Model-based Asynchronous Hyperparameter and Neural Architecture SearchThe acquisition function (EI) which is optimized in
get_config()
, is obtained by fixing the resource level \(r\) to a value which is determined depending on the current state. Ifresource_acq
== ‘bohb’, \(r\) is the largest value<= max_t
, where we have seen \(\ge \mathrm{dimension}(\mathbf{x})\) metric values. Ifresource_acq == "first"
, \(r\) is the first milestone which config \(\mathbf{x}\) would reach when started.Additional arguments on top of parent class
GPFIFOSearcher
.- Parameters:
model (str, optional) –
Selects surrogate model (learning curve model) to be used. Choices are:
”gp_multitask” (default): GP multi-task surrogate model
”gp_independent”: Independent GPs for each rung level, sharing an ARD kernel
”gp_issm”: Gaussian-additive model of ISSM type
”gp_expdecay”: Gaussian-additive model of exponential decay type (as in Freeze Thaw Bayesian Optimization)
gp_resource_kernel (str, optional) – Only relevant for
model == "gp_multitask"
. Surrogate model over criterion function \(f(\mathbf{x}, r)\), \(\mathbf{x}\) the config, \(r\) the resource. Note that \(\mathbf{x}\) is encoded to be a vector with entries in[0, 1]
, and \(r\) is linearly mapped to[0, 1]
, while the criterion data is normalized to mean 0, variance 1. The reference above provides details on the models supported here. For the exponential decay kernel, the base kernel over \(\mathbf{x}\) is Matern 5/2 ARD. SeeSUPPORTED_RESOURCE_MODELS
for supported choices. Defaults to “exp-decay-sum”resource_acq (str, optional) – Only relevant for ``model in
{"gp_multitask", "gp_independent"}
. Determines how the EI acquisition function is used. Values: “bohb”, “first”. Defaults to “bohb”max_size_data_for_model (int, optional) –
If this is set, we limit the number of observations the surrogate model is fitted on this value. If there are more observations, they are down sampled, see
SubsampleMultiFidelityStateConverter
for details. This down sampling is repeated every time the model is fit, which ensures that most recent data is taken into account. Theopt_skip_*
predicates are evaluated before the state is downsampled.Pass
None
not to apply such a threshold. The default isDEFAULT_MAX_SIZE_DATA_FOR_MODEL
.opt_skip_num_max_resource (bool, optional) – Parameter for surrogate model fitting, skip predicate. If
True
, and number of observations aboveopt_skip_init_length
, fitting is done only when there is a new datapoint atr = max_t
, and skipped otherwise. Defaults toFalse
issm_gamma_one (bool, optional) – Only relevant for
model == "gp_issm"
. IfTrue
, the gamma parameter of the ISSM is fixed to 1, otherwise it is optimized over. Defaults toFalse
expdecay_normalize_inputs (bool, optional) – Only relevant for
model == "gp_expdecay"
. IfTrue
, resource values r are normalized to[0, 1]
as input to the exponential decay surrogate model. Defaults toFalse
- configure_scheduler(scheduler)[source]
Some searchers need to obtain information from the scheduler they are used with, in order to configure themselves. This method has to be called before the searcher can be used.
- Parameters:
scheduler (
TrialScheduler
) – Scheduler the searcher is used with.
- register_pending(trial_id, config=None, milestone=None)[source]
Registers trial as pending. This means the corresponding evaluation task is running. Once it finishes, update is called for this trial.
- evaluation_failed(trial_id)[source]
Called by scheduler if an evaluation job for a trial failed.
The searcher should react appropriately (e.g., remove pending evaluations for this trial, not suggest the configuration again).
- Parameters:
trial_id (
str
) – ID of trial whose evaluated failed
- cleanup_pending(trial_id)[source]
Removes all pending evaluations for trial
trial_id
.This should be called after an evaluation terminates. For various reasons (e.g., termination due to convergence), pending candidates for this evaluation may still be present.
- Parameters:
trial_id (
str
) – ID of trial whose pending evaluations should be cleared
- remove_case(trial_id, **kwargs)[source]
Remove data case previously appended by
_update()
For searchers which maintain the dataset of all cases (reports) passed to update, this method allows to remove one case from the dataset.
- Parameters:
trial_id (
str
) – ID of trial whose data is to be removedkwargs – Extra arguments, optional
- clone_from_state(state)[source]
Together with
get_state()
, this is needed in order to store and re-create the mutable state of the searcher.Given state as returned by
get_state()
, this method combines the non-pickle-able part of the immutable state from self with state and returns the corresponding searcher clone. Afterwards,self
is not used anymore.- Parameters:
state – See above
- Returns:
New searcher object
Subpackages
- syne_tune.optimizer.schedulers.searchers.bayesopt package
- Subpackages
- syne_tune.optimizer.schedulers.searchers.bayesopt.datatypes package
- syne_tune.optimizer.schedulers.searchers.bayesopt.gpautograd package
- syne_tune.optimizer.schedulers.searchers.bayesopt.models package
- syne_tune.optimizer.schedulers.searchers.bayesopt.sklearn package
- syne_tune.optimizer.schedulers.searchers.bayesopt.tuning_algorithms package
- syne_tune.optimizer.schedulers.searchers.bayesopt.utils package
- Subpackages
- syne_tune.optimizer.schedulers.searchers.bore package
- syne_tune.optimizer.schedulers.searchers.botorch package
BoTorchSearcher
BoTorchSearcher.clone_from_state()
BoTorchSearcher.num_suggestions()
BoTorchSearcher.register_pending()
BoTorchSearcher.evaluation_failed()
BoTorchSearcher.cleanup_pending()
BoTorchSearcher.dataset_size()
BoTorchSearcher.configure_scheduler()
BoTorchSearcher.objectives()
BoTorchSearcher.metric_names()
BoTorchSearcher.metric_mode()
BotorchSearcher
- Submodules
- syne_tune.optimizer.schedulers.searchers.constrained package
- syne_tune.optimizer.schedulers.searchers.cost_aware package
- syne_tune.optimizer.schedulers.searchers.dyhpo package
DynamicHPOSearcher
DynamicHPOSearcher.configure_scheduler()
DynamicHPOSearcher.get_config()
DynamicHPOSearcher.on_trial_result()
DynamicHPOSearcher.register_pending()
DynamicHPOSearcher.remove_case()
DynamicHPOSearcher.evaluation_failed()
DynamicHPOSearcher.cleanup_pending()
DynamicHPOSearcher.dataset_size()
DynamicHPOSearcher.model_parameters()
DynamicHPOSearcher.score_paused_trials_and_new_configs()
DynamicHPOSearcher.get_state()
DynamicHPOSearcher.clone_from_state()
DynamicHPOSearcher.debug_log
- Submodules
- syne_tune.optimizer.schedulers.searchers.hypertune package
- syne_tune.optimizer.schedulers.searchers.kde package
- syne_tune.optimizer.schedulers.searchers.sklearn package
- syne_tune.optimizer.schedulers.searchers.utils package
HyperparameterRanges
HyperparameterRanges.internal_keys
HyperparameterRanges.config_space_for_sampling
HyperparameterRanges.to_ndarray()
HyperparameterRanges.to_ndarray_matrix()
HyperparameterRanges.ndarray_size
HyperparameterRanges.from_ndarray()
HyperparameterRanges.encoded_ranges
HyperparameterRanges.is_attribute_fixed()
HyperparameterRanges.random_config()
HyperparameterRanges.random_configs()
HyperparameterRanges.get_ndarray_bounds()
HyperparameterRanges.filter_for_last_pos_value()
HyperparameterRanges.config_to_tuple()
HyperparameterRanges.tuple_to_config()
HyperparameterRanges.config_to_match_string()
make_hyperparameter_ranges()
HyperparameterRangesImpl
LinearScaling
LogScaling
ReverseLogScaling
get_scaling()
- Submodules
- syne_tune.optimizer.schedulers.searchers.utils.common module
- syne_tune.optimizer.schedulers.searchers.utils.default_arguments module
- syne_tune.optimizer.schedulers.searchers.utils.exclusion_list module
- syne_tune.optimizer.schedulers.searchers.utils.hp_ranges module
- syne_tune.optimizer.schedulers.searchers.utils.hp_ranges_factory module
- syne_tune.optimizer.schedulers.searchers.utils.hp_ranges_impl module
HyperparameterRange
scale_from_zero_one()
HyperparameterRangeContinuous
HyperparameterRangeInteger
HyperparameterRangeFiniteRange
HyperparameterRangeCategorical
HyperparameterRangeCategoricalNonBinary
HyperparameterRangeCategoricalBinary
HyperparameterRangeOrdinalEqual
HyperparameterRangeOrdinalNearestNeighbor
HyperparameterRangesImpl
decode_extended_features()
- syne_tune.optimizer.schedulers.searchers.utils.scaling module
- syne_tune.optimizer.schedulers.searchers.utils.warmstarting module
Submodules
- syne_tune.optimizer.schedulers.searchers.bracket_distribution module
- syne_tune.optimizer.schedulers.searchers.gp_fifo_searcher module
- syne_tune.optimizer.schedulers.searchers.gp_multifidelity_searcher module
- syne_tune.optimizer.schedulers.searchers.gp_searcher_factory module
gp_fifo_searcher_factory()
gp_multifidelity_searcher_factory()
constrained_gp_fifo_searcher_factory()
cost_aware_coarse_gp_fifo_searcher_factory()
cost_aware_fine_gp_fifo_searcher_factory()
cost_aware_gp_multifidelity_searcher_factory()
hypertune_searcher_factory()
gp_fifo_searcher_defaults()
gp_multifidelity_searcher_defaults()
constrained_gp_fifo_searcher_defaults()
cost_aware_gp_fifo_searcher_defaults()
cost_aware_gp_multifidelity_searcher_defaults()
hypertune_searcher_defaults()
- syne_tune.optimizer.schedulers.searchers.gp_searcher_utils module
- syne_tune.optimizer.schedulers.searchers.model_based_searcher module
- syne_tune.optimizer.schedulers.searchers.random_grid_searcher module
- syne_tune.optimizer.schedulers.searchers.regularized_evolution module
- syne_tune.optimizer.schedulers.searchers.searcher module
impute_points_to_evaluate()
BaseSearcher
BaseSearcher.configure_scheduler()
BaseSearcher.get_config()
BaseSearcher.on_trial_result()
BaseSearcher.register_pending()
BaseSearcher.remove_case()
BaseSearcher.evaluation_failed()
BaseSearcher.cleanup_pending()
BaseSearcher.dataset_size()
BaseSearcher.model_parameters()
BaseSearcher.get_state()
BaseSearcher.clone_from_state()
BaseSearcher.debug_log
- syne_tune.optimizer.schedulers.searchers.searcher_base module
extract_random_seed()
sample_random_configuration()
StochasticSearcher
StochasticAndFilterDuplicatesSearcher
StochasticAndFilterDuplicatesSearcher.allow_duplicates
StochasticAndFilterDuplicatesSearcher.should_not_suggest()
StochasticAndFilterDuplicatesSearcher.get_config()
StochasticAndFilterDuplicatesSearcher.register_pending()
StochasticAndFilterDuplicatesSearcher.evaluation_failed()
StochasticAndFilterDuplicatesSearcher.get_state()
- syne_tune.optimizer.schedulers.searchers.searcher_callback module
- syne_tune.optimizer.schedulers.searchers.searcher_factory module