Loss is the gradient signal; metrics are the report card
You train against the loss. You evaluate against task-specific metrics. They're not the same number, and the gap matters.
Classification metrics
- Accuracy — fraction correctly predicted. Easy to interpret, useless when classes are imbalanced.
- Precision / Recall / F1 — per-class metrics that decompose accuracy into "of what I predicted positive, how much was actually positive (precision)" and "of all the actual positives, how many did I catch (recall)". F1 is their harmonic mean.
- Top-K accuracy — fraction where the true class is in your top K predictions. Standard for ImageNet (top-1, top-5).
- ROC AUC — area under the receiver operating characteristic. For binary classifiers; threshold-independent.
Regression metrics
- MAE / RMSE — mean absolute error and root mean squared error. Both in the units of your target.
- R² — fraction of variance explained.
Compute metrics on validation only, in eval mode, with inference_mode
You don't want metric computation polluting training-mode behavior (BatchNorm, Dropout) or building autograd graphs you don't need.
torchmetrics — when you don't want to roll your own
The torchmetrics package (separate install) has tested implementations of every common metric, including streaming variants that update incrementally over batches. For anything beyond accuracy, lean on it.