scico.ray.tune#

Parameter tuning using ray.tune.

Functions

run(run_or_experiment, metric, mode[, ...])

Simplified wrapper for ray.tune.run.

Classes

Tuner(trainable, *[, param_space, ...])

Simplified interface for ray.tune.Tuner.

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 to ray.tune.Tuner is 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) – If True, use HyperOptSearch search, otherwise use simple random search (see BasicVariantGenerator).

  • 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:

ExperimentAnalysis

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: Tuner

Simplified interface for ray.tune.Tuner.

Inheritance diagram of 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) – If True, reuse the same process/object for multiple hyperparameters.

  • hyperopt (bool) – If True, use HyperOptSearch search, otherwise use simple random search (see BasicVariantGenerator).

  • 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:

ResultGrid

Returns:

Result of parameter search.