tabensemb.model.AbstractNN.log#

method

AbstractNN.log(name: str, value: Metric | Tensor | int | float | Mapping[str, Metric | Tensor | int | float], prog_bar: bool = False, logger: bool | None = None, on_step: bool | None = None, on_epoch: bool | None = None, reduce_fx: str | Callable = 'mean', enable_graph: bool = False, sync_dist: bool = False, sync_dist_group: Any | None = None, add_dataloader_idx: bool = True, batch_size: int | None = None, metric_attribute: str | None = None, rank_zero_only: bool = False) None#

Log a key, value pair.

Example:

self.log('train_loss', loss)

The default behavior per hook is documented here: extensions/logging:Automatic Logging.

Parameters:
  • name – key to log.

  • value – value to log. Can be a float, Tensor, Metric, or a dictionary of the former.

  • prog_bar – if True logs to the progress bar.

  • logger – if True logs to the logger.

  • on_step – if True logs at this step. The default value is determined by the hook. See extensions/logging:Automatic Logging for details.

  • on_epoch – if True logs epoch accumulated metrics. The default value is determined by the hook. See extensions/logging:Automatic Logging for details.

  • reduce_fx – reduction function over step values for end of epoch. torch.mean() by default.

  • enable_graph – if True, will not auto detach the graph.

  • sync_dist – if True, reduces the metric across devices. Use with care as this may lead to a significant communication overhead.

  • sync_dist_group – the DDP group to sync across.

  • add_dataloader_idx – if True, appends the index of the current dataloader to the name (when using multiple dataloaders). If False, user needs to give unique names for each dataloader to not mix the values.

  • batch_size – Current batch_size. This will be directly inferred from the loaded batch, but for some data structures you might need to explicitly provide it.

  • metric_attribute – To restore the metric state, Lightning requires the reference of the torchmetrics.Metric in your model. This is found automatically if it is a model attribute.

  • rank_zero_only – Whether the value will be logged only on rank 0. This will prevent synchronization which would produce a deadlock as not all processes would perform this log call.