TensorBoardLogger¶
- class torchtune.utils.metric_logging.TensorBoardLogger(log_dir: str, organize_logs: bool = True, **kwargs)[source]¶
Logger for use w/ PyTorch’s implementation of TensorBoard (https://pytorch.org/docs/stable/tensorboard.html).
- Parameters:
log_dir (str) – TensorBoard log directory
organize_logs (bool) – If True, this class will create a subdirectory within log_dir for the current run. Having sub-directories allows you to compare logs across runs. When TensorBoard is passed a logdir at startup, it recursively walks the directory tree rooted at logdir looking for subdirectories that contain tfevents data. Every time it encounters such a subdirectory, it loads it as a new run, and the frontend will organize the data accordingly. Recommended value is True. Run tensorboard –logdir my_log_dir to view the logs.
**kwargs – additional arguments
Example
>>> from torchtune.utils.metric_logging import TensorBoardLogger >>> logger = TensorBoardLogger(log_dir="my_log_dir") >>> logger.log("my_metric", 1.0, 1) >>> logger.log_dict({"my_metric": 1.0}, 1) >>> logger.close()
Note
This utility requires the tensorboard package to be installed. You can install it with pip install tensorboard. In order to view TensorBoard logs, you need to run tensorboard –logdir my_log_dir in your terminal.
- close() None [source]¶
Close log resource, flushing if necessary. Logs should not be written after close is called.