Calculating accuracy using torchmetrics
Tracking accuracy during training helps identify the best-performing epoch.
In this exercise, you'll use torchmetrics to calculate accuracy on a facemask dataset with three classes. The plot_errors function will highlight misclassified samples, helping you analyze model errors.
torchmetrics package is already imported. Model outputs are softmax probabilities, and labels are one-hot encoded vectors.
Questo esercizio fa parte del corso
Introduction to Deep Learning with PyTorch
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Create accuracy metric
metric = torchmetrics.____(____, ____)
for features, labels in dataloader:
outputs = model(features)
# Calculate accuracy over the batch
metric.____(____, ____)