.. _loggers-docstring: Loggers (tune.logger) ===================== Tune has default loggers for Tensorboard, CSV, and JSON formats. Logging Path ------------ Tune will log the results of each trial to a subfolder under a specified local dir, which defaults to ``~/ray_results``. .. code-block:: python # This logs to 2 different trial folders: # ~/ray_results/trainable_name/trial_name_1 and ~/ray_results/trainable_name/trial_name_2 # trainable_name and trial_name are autogenerated. tune.run(trainable, num_samples=2) You can specify the ``local_dir`` and ``trainable_name``: .. code-block:: python # This logs to 2 different trial folders: # ./results/test_experiment/trial_name_1 and ./results/test_experiment/trial_name_2 # Only trial_name is autogenerated. tune.run(trainable, num_samples=2, local_dir="./results", name="test_experiment") To specify custom trial folder names, you can pass use the ``trial_name_creator`` argument to `tune.run`. This takes a function with the following signature: .. code-block:: python def trial_name_string(trial): """ Args: trial (Trial): A generated trial object. Returns: trial_name (str): String representation of Trial. """ return str(trial) tune.run( MyTrainableClass, name="example-experiment", num_samples=1, trial_name_creator=trial_name_string ) See the documentation on Trials: :ref:`trial-docstring`. Custom Loggers -------------- You can pass in your own logging mechanisms to output logs in custom formats as follows: .. code-block:: python from ray.tune.logger import DEFAULT_LOGGERS tune.run( MyTrainableClass, name="experiment_name", loggers=DEFAULT_LOGGERS + (CustomLogger1, CustomLogger2) ) These loggers will be called along with the default Tune loggers. All loggers must inherit the Logger interface (:ref:`logger-interface`). You can also check out `logger.py `__ for implementation details. An example can be found in `logging_example.py `__. Viskit ------ Tune automatically integrates with `Viskit `_ via the ``CSVLogger`` outputs. To use VisKit (you may have to install some dependencies), run: .. code-block:: bash $ git clone https://github.com/rll/rllab.git $ python rllab/rllab/viskit/frontend.py ~/ray_results/my_experiment The nonrelevant metrics (like timing stats) can be disabled on the left to show only the relevant ones (like accuracy, loss, etc.). .. image:: /ray-tune-viskit.png .. _logger-interface: Logger ------ .. autoclass:: ray.tune.logger.Logger UnifiedLogger ------------- .. autoclass:: ray.tune.logger.UnifiedLogger TBXLogger --------- .. autoclass:: ray.tune.logger.TBXLogger JsonLogger ---------- .. autoclass:: ray.tune.logger.JsonLogger CSVLogger --------- .. autoclass:: ray.tune.logger.CSVLogger MLFLowLogger ------------ Tune also provides a default logger for `MLFlow `_. You can install MLFlow via ``pip install mlflow``. An example can be found `mlflow_example.py `__. Note that this currently does not include artifact logging support. For this, you can use the native MLFlow APIs inside your Trainable definition. .. autoclass:: ray.tune.logger.MLFLowLogger