Skip to content

Commit f6b8b69

Browse files
edward-iolexierule
authored andcommitted
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. (cherry picked from commit f3442db)
1 parent 9443bb1 commit f6b8b69

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pytorch_lightning/utilities/metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ def metrics_to_scalars(metrics: Any) -> Any:
2727
2828
Raises:
2929
MisconfigurationException:
30-
If ``value`` contains multiple elements, hence preventing conversion to ``float``
30+
If tensors inside ``metrics`` contains multiple elements, hence preventing conversion to a scalar.
3131
"""
3232

3333
def to_item(value: torch.Tensor) -> numbers.Number:
3434
if value.numel() != 1:
3535
raise MisconfigurationException(
36-
f"The metric `{value}` does not contain a single element" f" thus it cannot be converted to float."
36+
f"The metric `{value}` does not contain a single element, thus it cannot be converted to a scalar."
3737
)
3838
return value.item()
3939

0 commit comments

Comments
 (0)