From e8ad72ef9085f72da4417ec29da8d86670df3b1a Mon Sep 17 00:00:00 2001 From: Nicki Skafte Detlefsen <skaftenicki@gmail.com> Date: Mon, 25 Oct 2021 16:47:45 +0200 Subject: [PATCH] Improve docs on logging in lightning (#582) --- docs/source/pages/lightning.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/pages/lightning.rst b/docs/source/pages/lightning.rst index 0261ce91d65..b547b13f3fe 100644 --- a/docs/source/pages/lightning.rst +++ b/docs/source/pages/lightning.rst @@ -39,6 +39,12 @@ The example below shows how to use a metric in your `LightningModule <https://py # log epoch metric self.log('train_acc_epoch', self.accuracy.compute()) +.. note:: + ``self.log`` in Lightning only supports logging of *scalar-tensors*. While the vast majority of metrics in torchmetrics returns a scalar tensor, some metrics such as + :class:`~torchmetrics.ConfusionMatrix`, :class:`~torchmetrics.ROC`, :class:`~torchmetrics.MAP`, :class:`~torchmetrics.RougeScore` return outputs that are non-scalar + tensors (often dicts or list of tensors) and should therefore be dealt with separately. For info about the return type and shape please look at the documentation for + the ``compute`` method for each metric you want to log. + ******************** Logging TorchMetrics ********************