ray.tune.Callback#
- class ray.tune.Callback[source]#
Tune base callback that can be extended and passed to a
TrialRunner
Tune callbacks are called from within the
TrialRunner
class. There are several hooks that can be used, all of which are found in the submethod definitions of this base class.The parameters passed to the
**info
dict vary between hooks. The parameters passed are described in the docstrings of the methods.This example will print a metric each time a result is received:
from ray import train, tune from ray.tune import Callback class MyCallback(Callback): def on_trial_result(self, iteration, trials, trial, result, **info): print(f"Got result: {result['metric']}") def train_func(config): for i in range(10): tune.report(metric=i) tuner = tune.Tuner( train_func, run_config=train.RunConfig( callbacks=[MyCallback()] ) ) tuner.fit()
PublicAPI (beta): This API is in beta and may change before becoming stable.
Methods
Get the state of the callback.
Called after a trial saved a checkpoint with Tune.
Called after experiment is over and all trials have concluded.
Called at the start of each tuning loop step.
Called at the end of each tuning loop step.
Called after a trial instance completed.
Called after a trial instance failed (errored).
Called after a trial instance failed (errored) but the trial is scheduled for retry.
Called after restoring a trial instance.
Called after receiving a result from a trial.
Called after receiving a checkpoint from a trial.
Called after starting a trial instance.
Set the state of the callback.
Called once at the very beginning of training.