Loggers (tune.logger)

Tune automatically uses loggers for TensorBoard, CSV, and JSON formats. By default, Tune only logs the returned result dictionaries from the training function.

If you need to log something lower level like model weights or gradients, see Trainable Logging.


Tune’s per-trial Logger classes have been deprecated. They can still be used, but we encourage you to use our new interface with the LoggerCallback class instead.


Tune automatically integrates with Viskit via the CSVLoggerCallback outputs. To use VisKit (you may have to install some dependencies), run:

$ git clone https://github.com/rll/rllab.git
$ python rllab/rllab/viskit/frontend.py ~/ray_results/my_experiment

The non-relevant metrics (like timing stats) can be disabled on the left to show only the relevant ones (like accuracy, loss, etc.).



class ray.tune.logger.TBXLoggerCallback[source]

TensorBoardX Logger.

Note that hparams will be written only after a trial has terminated. This logger automatically flattens nested dicts to show on TensorBoard:

{“a”: {“b”: 1, “c”: 2}} -> {“a/b”: 1, “a/c”: 2}


class ray.tune.logger.JsonLoggerCallback[source]

Logs trial results in json format.

Also writes to a results file and param.json file when results or configurations are updated. Experiments must be executed with the JsonLoggerCallback to be compatible with the ExperimentAnalysis tool.


class ray.tune.logger.CSVLoggerCallback[source]

Logs results to progress.csv under the trial directory.

Automatically flattens nested dicts in the result dict before writing to csv:

{“a”: {“b”: 1, “c”: 2}} -> {“a/b”: 1, “a/c”: 2}


Tune also provides a logger for MLflow. You can install MLflow via pip install mlflow. You can see the tutorial here.


Tune also provides a logger for Weights & Biases. You can install Wandb via pip install wandb. You can see the tutorial here


class ray.tune.logger.LoggerCallback[source]

Base class for experiment-level logger callbacks

This base class defines a general interface for logging events, like trial starts, restores, ends, checkpoint saves, and receiving trial results.

Callbacks implementing this interface should make sure that logging utilities are cleaned up properly on trial termination, i.e. when log_trial_end is received. This includes e.g. closing files.

PublicAPI: This API is stable across Ray releases.

log_trial_start(trial: Trial)[source]

Handle logging when a trial starts.


trial – Trial object.

log_trial_restore(trial: Trial)[source]

Handle logging when a trial restores.


trial – Trial object.

log_trial_save(trial: Trial)[source]

Handle logging when a trial saves a checkpoint.


trial – Trial object.

log_trial_result(iteration: int, trial: Trial, result: Dict)[source]

Handle logging when a trial reports a result.

  • trial – Trial object.

  • result – Result dictionary.

log_trial_end(trial: Trial, failed: bool = False)[source]

Handle logging when a trial ends.

  • trial – Trial object.

  • failed – True if the Trial finished gracefully, False if it failed (e.g. when it raised an exception).