Skip to content

Metric

minnt.Metric

Bases: Protocol

An abstract metric interface.

Note

Metrics are expected to be instances of torch.nn.Module and are stored in a torch.nn.ModuleDict.

update

update(y: Tensor, y_true: Tensor) -> Any

Update the internal state of the metric with new predictions and gold targets.

Parameters:

  • y (Tensor) –

    The predicted outputs.

  • y_true (Tensor) –

    The ground-truth targets.

Returns:

  • Any

    anything; Minnt metrics return Self, but any return value is allowed in the generic interface (torchmetrics metrics return None, for example).

compute

compute() -> Tensor

Compute the accumulated metric value.

Returns:

  • Tensor

    A (usually scalar) tensor representing the accumulated metric value.

reset

reset() -> Any

Reset the internal state of the metric.

Returns:

  • Any

    anything; Minnt metrics return Self, but any return value is allowed in the generic interface (torchmetrics metrics return None, for example).