Metrics

Classification metrics computed on tensors.

FunctionDescription
accuracy pred targetFraction of matching elements between predictions and targets.
Both tensors must have the same shape (class indices, not logits).
accuracyFromLogits logits targetAccuracy from logits: take argmax over the last dimension, then compare to target indices.
f1 numClasses pred targetPer-class F1 score: 2precisionrecall/(precision+recall)2 \cdot \text{precision} \cdot \text{recall} / (\text{precision} + \text{recall}).
precision numClasses pred targetPer-class precision: TP / (TP + FP). Returns NaN for classes with no predicted positives.
recall numClasses pred targetPer-class recall: TP / (TP + FN). Returns NaN for classes with no actual positives.

accuracy

accuracy pred target

Fraction of matching elements between predictions and targets. Both tensors must have the same shape (class indices, not logits).

Parameters

  • pred : Tensor
  • target : Tensor

Returns float


accuracyFromLogits

accuracyFromLogits logits target

Accuracy from logits: take argmax over the last dimension, then compare to target indices.

Parameters

  • logits : Tensor
  • target : Tensor

Returns float


f1

f1 numClasses pred target

Per-class F1 score: 2precisionrecall/(precision+recall)2 \cdot \text{precision} \cdot \text{recall} / (\text{precision} + \text{recall}).

Parameters

  • numClasses : int
  • pred : Tensor
  • target : Tensor

Returns float list


precision

precision numClasses pred target

Per-class precision: TP / (TP + FP). Returns NaN for classes with no predicted positives.

Parameters

  • numClasses : int
  • pred : Tensor
  • target : Tensor

Returns float list


recall

recall numClasses pred target

Per-class recall: TP / (TP + FN). Returns NaN for classes with no actual positives.

Parameters

  • numClasses : int
  • pred : Tensor
  • target : Tensor

Returns float list