TensorBoardLogger — PyTorch Lightning 2.5.1.post0 documentation (original) (raw)

class lightning.pytorch.loggers.TensorBoardLogger(save_dir, name='lightning_logs', version=None, log_graph=False, default_hp_metric=True, prefix='', sub_dir=None, **kwargs)[source]

Bases: Logger, TensorBoardLogger

Log to local or remote file system in TensorBoard format.

Implemented using SummaryWriter. Logs are saved toos.path.join(save_dir, name, version). This is the default logger in Lightning, it comes preinstalled.

This logger supports logging to remote filesystems via fsspec. Make sure you have it installed and you don’t have tensorflow (otherwise it will use tf.io.gfile instead of fsspec).

Example:

from lightning.pytorch import Trainer from lightning.pytorch.loggers import TensorBoardLogger

logger = TensorBoardLogger("tb_logs", name="my_model") trainer = Trainer(logger=logger)

Parameters:

after_save_checkpoint(checkpoint_callback)[source]

Called after model checkpoint callback saves a new checkpoint.

Parameters:

checkpoint_callback (ModelCheckpoint) – the model checkpoint callback instance

Return type:

None

finalize(status)[source]

Do any processing that is necessary to finalize an experiment.

Parameters:

status (str) – Status that the experiment finished with (e.g. success, failed, aborted)

Return type:

None

log_graph(model, input_array=None)[source]

Record model graph.

Parameters:

Return type:

None

log_hyperparams(params, metrics=None, step=None)[source]

Record hyperparameters. TensorBoard logs with and without saved hyperparameters are incompatible, the hyperparameters are then not displayed in the TensorBoard. Please delete or move the previously saved logs to display the new ones with hyperparameters.

Parameters:

Return type:

None

save()[source]

Save log data.

Return type:

None

property log_dir_: str_

The directory for this run’s tensorboard checkpoint.

By default, it is named 'version_${self.version}' but it can be overridden by passing a string value for the constructor’s version parameter instead of None or an int.

property root_dir_: str_

Parent directory for all tensorboard checkpoint subdirectories.

If the experiment name parameter is an empty string, no experiment subdirectory is used and the checkpoint will be saved in “save_dir/version”

property save_dir_: str_

Gets the save directory where the TensorBoard experiments are saved.

Returns:

The local path to the save directory where the TensorBoard experiments are saved.