From f3442db3f0155a32c8bc0ca3bc943d4b0039897f Mon Sep 17 00:00:00 2001 From: edward-io <53842584+edward-io@users.noreply.github.com> Date: Sat, 7 Aug 2021 03:03:36 -0700 Subject: [PATCH] Fix comments for metrics_to_scalars (#8782) metrics_to_scalars can return non-float values, such as int or complex, depending on the dtype of the tensor. --- pytorch_lightning/utilities/metrics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytorch_lightning/utilities/metrics.py b/pytorch_lightning/utilities/metrics.py index 0c6ade8082..d10f9a8045 100644 --- a/pytorch_lightning/utilities/metrics.py +++ b/pytorch_lightning/utilities/metrics.py @@ -27,13 +27,13 @@ def metrics_to_scalars(metrics: Any) -> Any: Raises: MisconfigurationException: - If ``value`` contains multiple elements, hence preventing conversion to ``float`` + If tensors inside ``metrics`` contains multiple elements, hence preventing conversion to a scalar. """ def to_item(value: torch.Tensor) -> numbers.Number: if value.numel() != 1: raise MisconfigurationException( - f"The metric `{value}` does not contain a single element" f" thus it cannot be converted to float." + f"The metric `{value}` does not contain a single element, thus it cannot be converted to a scalar." ) return value.item()