pytorch_lightning.metrics.metric module¶
-
class
pytorch_lightning.metrics.metric.
Metric
(name)[source]¶ Bases:
pytorch_lightning.utilities.device_dtype_mixin.DeviceDtypeModuleMixin
,torch.nn.Module
,abc.ABC
Abstract base class for metric implementation.
Should be used to implement metrics that 1. Return multiple Outputs 2. Handle their own DDP sync
-
class
pytorch_lightning.metrics.metric.
NumpyMetric
(name, reduce_group=None, reduce_op=None)[source]¶ Bases:
pytorch_lightning.metrics.metric.Metric
Base class for metric implementation operating on numpy arrays. All inputs will be casted to numpy if necessary and all outputs will be casted to tensors if necessary. Already handles DDP sync and input/output conversions.
- Parameters
-
class
pytorch_lightning.metrics.metric.
TensorCollectionMetric
(name, reduce_group=None, reduce_op=None)[source]¶ Bases:
pytorch_lightning.metrics.metric.Metric
Base class for metric implementation operating directly on tensors. All inputs will be casted to tensors if necessary. Outputs won’t be casted. Already handles DDP sync and input conversions.
This class differs from
TensorMetric
, as it assumes all outputs to be collections of tensors and does not explicitly convert them. This is necessary, since some collections (like for ROC, Precision-Recall Curve etc.) cannot be converted to tensors at the highest level. All numpy arrays and numbers occuring in these outputs will still be converted.Use this class as a baseclass, whenever you want to ensure inputs are tensors and outputs cannot be converted to tensors automatically
- Parameters
-
class
pytorch_lightning.metrics.metric.
TensorMetric
(name, reduce_group=None, reduce_op=None)[source]¶ Bases:
pytorch_lightning.metrics.metric.Metric
Base class for metric implementation operating directly on tensors. All inputs and outputs will be casted to tensors if necessary. Already handles DDP sync and input/output conversions.
- Parameters