ray.tune.stopper.CombinedStopper#

class ray.tune.stopper.CombinedStopper(*stoppers: Stopper)[source]#

Bases: Stopper

Combine several stoppers via ‘OR’.

Parameters:

*stoppers – Stoppers to be combined.

Examples

>>> import numpy as np
>>> from ray import train, tune
>>> from ray.tune.stopper import (
...     CombinedStopper,
...     MaximumIterationStopper,
...     TrialPlateauStopper,
... )
>>>
>>> stopper = CombinedStopper(
...     MaximumIterationStopper(max_iter=10),
...     TrialPlateauStopper(metric="my_metric"),
... )
>>> def train_fn(config):
...     for i in range(15):
...         train.report({"my_metric": np.random.normal(0, 1 - i / 15)})
...
>>> tuner = tune.Tuner(
...     train_fn,
...     run_config=train.RunConfig(stop=stopper),
... )
>>> print("[ignore]"); result_grid = tuner.fit()  
[ignore]...
>>> all(result.metrics["training_iteration"] <= 20 for result in result_grid)
True

Methods