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.
Bu egzersiz
Introduction to Deep Learning with PyTorch
kursunun bir parçasıdırUygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Create accuracy metric
metric = torchmetrics.____(____, ____)
for features, labels in dataloader:
outputs = model(features)
# Calculate accuracy over the batch
metric.____(____, ____)