Skip to content

nexuml_library.layers.loss.classification_metrics

nexuml_library.layers.loss.classification_metrics

Classification metrics layer.

Supports both multiclass and multilabel classification metrics via the multi_label flag. In multilabel mode, sigmoid is applied to logits before updating metrics and labels are kept as multi-hot vectors.

ClassificationMetrics

Bases: LayerDefinition

Accumulate classification metrics with torchmetrics.

When multi_label is False (default) the layer uses multiclass metrics (MulticlassAccuracy, MulticlassF1Score, MulticlassAveragePrecision). Labels are expected as integer class indices with shape [batch].

When multi_label is True the layer uses multilabel metrics (MultilabelAccuracy, MultilabelF1Score, MultilabelAveragePrecision). Sigmoid is applied to logits before passing them to the metrics and labels are expected as multi-hot float tensors with shape [batch, num_labels].