ray.tune.Experiment#

class ray.tune.Experiment(name: str, run: str | Callable | Type, *, stop: Mapping | Stopper | Callable[[str, Mapping], bool] | None = None, time_budget_s: int | float | timedelta | None = None, config: Dict[str, Any] | None = None, resources_per_trial: None | Mapping[str, float | int | Mapping] | PlacementGroupFactory = None, num_samples: int = 1, storage_path: str | None = None, storage_filesystem: pyarrow.fs.FileSystem | None = None, sync_config: SyncConfig | dict | None = None, checkpoint_config: CheckpointConfig | dict | None = None, trial_name_creator: Callable[[Trial], str] | None = None, trial_dirname_creator: Callable[[Trial], str] | None = None, log_to_file: bool = False, export_formats: Sequence | None = None, max_failures: int = 0, restore: str | None = None, local_dir: str | None = None)[source]#

Tracks experiment specifications.

Implicitly registers the Trainable if needed. The args here take the same meaning as the arguments defined tune.py:run.

experiment_spec = Experiment(
    "my_experiment_name",
    my_func,
    stop={"mean_accuracy": 100},
    config={
        "alpha": tune.grid_search([0.2, 0.4, 0.6]),
        "beta": tune.grid_search([1, 2]),
    },
    resources_per_trial={
        "cpu": 1,
        "gpu": 0
    },
    num_samples=10,
    local_dir="~/ray_results",
    checkpoint_freq=10,
    max_failures=2)

DeveloperAPI: This API may change across minor Ray releases.

Methods

from_json

Generates an Experiment object from JSON.

get_trainable_name

Get Trainable name.

register_if_needed

Registers Trainable or Function at runtime.

Attributes

PUBLIC_KEYS

checkpoint_config

checkpoint_dir

local_dir

local_path

path

public_spec

Returns the spec dict with only the public-facing keys.

remote_path

run_identifier

Returns a string representing the trainable identifier.

stopper