Skip to content

Metrics Documentation

Qisheng Robert He edited this page Jan 12, 2024 · 7 revisions

Classes

Metric

The basic metric class

  • extends: torch.nn.Module
  • Could be use as a decorator of a function
  • Metric tensor is released from memory as soon as the result returned
  • [Deprecation Warning]: Method call is deprecated from v1.0.0 and will be removed from v1.1.0, override the forward method instead."
  • Properties
    • result: The torch.Tensor of average metric results
  • Methods
    • Constructor
      • Parameters:
        • metric_fn: An optional Callable metrics function that accepts Any kind of prediction input and target and returns a metric torch.Tensor. A call method must be overriden if this parameter is set as None.
        • target: A str of target name in input and target during direct calling
    • forward
      • Forward the current result method
      • Parameters:
        • input: The prediction, or y_pred, in Any kind
        • target: The label, or y_true, in Any kind
      • Returns: The metric in torch.Tensor
    • reset
      • Reset the current results list

Accuracy

The traditional accuracy metric to compare two torch.Tensor

  • extends: Metric

SparseCategoricalAccuracy

The accuracy metric for normal integer labels

  • extends: Accuracy
  • Properties: - dim: An int of the probability dim index for the input
  • Constructor - Parameters: - dim: An int of the classification dimension - target: A str of target name in input and target during direct calling

CategoricalAccuracy

The accuracy metric for categorical labels

  • extends: SparseCategoricalAccuracy

BinaryConfusionMetric

The binary confusion metrics that calculates TP, FP, and FN and forward further to calculate the final metric

  • extends: .metric.Metric
  • Abstract class

ConfusionMetrics

The metric that calculates confusion metrics

  • extends: Metric
  • Constructor - Parameters: - num_classes: An int of the total number of classes - target: A str of target name in input and target during direct calling
  • Methods to implement: - forward_metric: The main method that accepts TP, TN, FP, and FN as torch.Tensor and returns the final metric as torch.Tensor

Dice

The dice score metrics

  • extends: BinaryConfusionMetric

F1

The f1 score metrics

  • extends: BinaryConfusionMetric

FeatureMetric

A metric that extracts inputs and targets with feature extractor and evaluates the extracted features instead of raw inputs

  • Extends: .metric.Metric
  • Generic class of Module
  • Parameters: - feature_extractor: A Module to extract the features

ExtractorScore

A general feature score metric which can be used as InceptionScore by taking the feature_extractor as an InceptionV3 model

  • Extends: FeatureExtractorMetric
  • Generic class of Module

FID

Fréchet Inception Distance (FID) metric

  • Extends: FeatureExtractorMetric
  • Generic class of Module
  • Properties: - use_linalg: A bool flag of if use scipy.linalg package

InstanceIoU

The iIoU metric for segmentation

  • extends: ConfusionMetrics

MAE

The Mean Absolute Error metric

  • extends: Metric
  • Properties: - reduction: A .loss.Reduction of reduction method

MeanIoU

The mIoU metric for segmentation

  • extends: Metric
  • The old MIoU metric in v1.0.3 calculates iIoU and has been renamed to InstanceIoU
  • Constructor - Parameters: - dim: An int of class dimension - smooth: A float of smooth value to avoid zero devision

PartialDice

The partial dice score for a specific class index

  • extends Dice
  • Properties: - class_idx: An int of the target class index

Precision

The precision score metric

  • extends: BinaryConfusionMetric

Recall

The recall score metric

  • extends: BinaryConfusionMetric

SSIM

The Structural Similarity Index metric

  • extends: Metrics
  • Properties: - window: A random gaussian window - window_size: An int of the window size

Methods

metric

The metric wrapping function that wrap a function into a metric

  • Use as a decorator
Clone this wiki locally