pytorch_lightning.loggers.tensorboard module¶
TensorBoard¶
-
class
pytorch_lightning.loggers.tensorboard.TensorBoardLogger(save_dir, name='default', version=None, log_graph=True, **kwargs)[source]¶ Bases:
pytorch_lightning.loggers.base.LightningLoggerBaseLog to local 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.Example
>>> from pytorch_lightning import Trainer >>> from pytorch_lightning.loggers import TensorBoardLogger >>> logger = TensorBoardLogger("tb_logs", name="my_model") >>> trainer = Trainer(logger=logger)
- Parameters
name¶ (
Optional[str]) – Experiment name. Defaults to'default'. If it is the empty string then no per-experiment subdirectory is used.version¶ (
Union[int,str,None]) – Experiment version. If version is not specified the logger inspects the save directory for existing versions, then automatically assigns the next available version. If it is a string then it is used as the run-specific subdirectory name, otherwise'version_${version}'is used.log_graph¶ (
bool) – Adds the computational graph to tensorboard. This requires that the user has defined the self.example_input_array attribute in their model.**kwargs¶ – Other arguments are passed directly to the
SummaryWriterconstructor.
-
log_graph(model, input_array=None)[source]¶ Record model graph
- Parameters
model¶ (
LightningModule) – lightning modelinput_array¶ – input passes to model.forward
-
log_metrics(metrics, step=None)[source]¶ Records metrics. This method logs metrics as as soon as it received them. If you want to aggregate metrics for one specific step, use the
agg_and_log_metrics()method.
-
property
experiment[source]¶ Actual tensorboard object. To use TensorBoard features in your
LightningModuledo the following.Example:
self.logger.experiment.some_tensorboard_function()
- Return type
SummaryWriter
-
property
log_dir[source]¶ 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 ofNoneor an int.- Return type
-
property
root_dir[source]¶ Parent directory for all tensorboard checkpoint subdirectories. If the experiment name parameter is
Noneor the empty string, no experiment subdirectory is used and the checkpoint will be saved in “save_dir/version_dir”- Return type