ray.tune.stopper.CombinedStopper#

class ray.tune.stopper.CombinedStopper(*stoppers: Stopper)[源代码]#

基类:Stopper

通过 ‘OR’ 组合多个停止符。

参数:

*stoppers – 要组合的止动器。

示例

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

方法