scico.ray.tune¶
Parameter tuning using ray.tune.
Functions
|
Simplified wrapper for ray.tune.run. |
Classes
|
Simplified interface for |
- scico.ray.tune.run(run_or_experiment, metric, mode, time_budget_s=None, num_samples=1, resources_per_trial=None, max_concurrent_trials=None, config=None, hyperopt=True, verbose=True, storage_path=None)[source]¶
Simplified wrapper for ray.tune.run.
The ray.tune.run interface appears to be scheduled for deprecation. Use of
Tuner, which is a simplified interface toray.tune.Tuneris recommended instead.- Parameters:
run_or_experiment (
Union[str,Callable,Type]) – Function that reports performance values.metric (
str) – Name of the metric reported in the performance evaluation function.mode (
str) – Either “min” or “max”, indicating which represents better performance.time_budget_s (
Union[None,int,float,timedelta]) – Maximum time allowed in seconds for the parameter search.num_samples (
int) – Number of parameter evaluation samples to compute.resources_per_trial (
Optional[Mapping[str,Union[float,int,Mapping]]]) – A dict mapping keys “cpu” and “gpu” to integers specifying the corresponding resources to allocate for each performance evaluation trial.max_concurrent_trials (
Optional[int]) – Maximum number of trials to run concurrently.config (
Optional[Dict[str,Any]]) – Specification of the parameter search space.hyperopt (
bool) – IfTrue, useHyperOptSearchsearch, otherwise use simple random search (seeBasicVariantGenerator).verbose (
bool) – Flag indicating whether verbose operation is desired. When verbose operation is enabled, the number of pending, running, and terminated trials are indicated by “P:”, “R:”, and “T:” respectively, followed by the current best metric value and the parameters at which it was reported.storage_path (
Optional[str]) – Directory in which to save tuning results. Defaults to a subdirectory “<username>/ray_results” within the path returned by tempfile.gettempdir(), corresponding e.g. to “/tmp/<username>/ray_results” under Linux.
- Return type:
- Returns:
Result of parameter search.
- class scico.ray.tune.Tuner(trainable, *, param_space=None, resources=None, max_concurrent_trials=None, metric=None, mode=None, num_samples=None, num_iterations=None, time_budget=None, reuse_actors=True, hyperopt=True, verbose=True, storage_path=None, **kwargs)[source]¶
Bases:
TunerSimplified interface for
ray.tune.Tuner.- Parameters:
trainable (
Union[Type[Trainable],Callable]) – Function that reports performance values.param_space (
Optional[Dict[str,Any]]) – Specification of the parameter search space.resources (
Optional[Dict]) – A dict mapping keys “cpu” and “gpu” to integers specifying the corresponding resources to allocate for each performance evaluation trial.max_concurrent_trials (
Optional[int]) – Maximum number of trials to run concurrently.metric (
Optional[str]) – Name of the metric reported in the performance evaluation function.mode (
Optional[str]) – Either “min” or “max”, indicating which represents better performance.num_samples (
Optional[int]) – Number of parameter evaluation samples to compute.num_iterations (
Optional[int]) – Number of training iterations for evaluation of a single configuration. Only required for the Tune Class API.time_budget (
Optional[int]) – Maximum time allowed in seconds for a single parameter evaluation.reuse_actors (
bool) – IfTrue, reuse the same process/object for multiple hyperparameters.hyperopt (
bool) – IfTrue, useHyperOptSearchsearch, otherwise use simple random search (seeBasicVariantGenerator).verbose (
bool) – Flag indicating whether verbose operation is desired. When verbose operation is enabled, the number of pending, running, and terminated trials are indicated by “P:”, “R:”, and “T:” respectively, followed by the current best metric value and the parameters at which it was reported.storage_path (
Optional[str]) – Directory in which to save tuning results. Defaults to a subdirectory “<username>/ray_results” within the path returned by tempfile.gettempdir(), corresponding e.g. to “/tmp/<username>/ray_results” under Linux.
- fit()[source]¶
Initialize ray and call
ray.tune.Tuner.fit.Initialize ray if not already initialized, and call
ray.tune.Tuner.fit. If ray was not previously initialized, shut it down after fit process has completed.- Return type:
- Returns:
Result of parameter search.