syne_tune.backend.python_backend.python_backend module
- class syne_tune.backend.python_backend.python_backend.PythonBackend(tune_function, config_space, rotate_gpus=True, delete_checkpoints=False)[source]
Bases:
LocalBackend
A backend that supports the tuning of Python functions (if you rather want to tune an endpoint script such as “train.py”, then you should use
LocalBackend
). The functiontune_function
should be serializable, should not reference any global variable or module and should have as arguments a subset of the keys ofconfig_space
. When deserializing, a md5 is checked to ensure consistency.For instance, the following function is a valid way of defining a backend on top of a simple function:
from syne_tune.backend import PythonBackend from syne_tune.config_space import uniform def f(x, epochs): import logging import time from syne_tune import Reporter root = logging.getLogger() root.setLevel(logging.DEBUG) reporter = Reporter() for i in range(epochs): reporter(epoch=i + 1, y=x + i) config_space = { "x": uniform(-10, 10), "epochs": 5, } backend = PythonBackend(tune_function=f, config_space=config_space)
See
examples/launch_height_python_backend.py
for a complete example.Additional arguments on top of parent class
LocalBackend
:- Parameters:
tune_function (
Callable
) – Python function to be tuned. The function must call Syne Tune reporter to report metrics and be serializable, imports should be performed inside the function body.config_space (
Dict
[str
,object
]) – Configuration space corresponding to arguments oftune_function
- property tune_function_path: Path
- set_path(results_root=None, tuner_name=None)[source]
- Parameters:
results_root (
Optional
[str
]) – The local folder that should contain the results of the tuning experiment. Used byTuner
to indicate a desired path where the results should be written to. This is used to unify the location of backend files andTuner
results when possible (in the local backend). By default, the backend does not do anything since not all backends may be able to unify their file locations.tuner_name (
Optional
[str
]) – Name of the tuner, can be used for instance to save checkpoints on remote storage.