Skip to content
Discussion options

You must be logged in to vote

It is currently not supported in the accuracy metric, but we have an open PR for implementing that exact feature Lightning-AI/torchmetrics#155

Currently what you can is instead calculate the confusion matrix and then ignore some classes based on that (remember that the true positive/correctly classified are found on the diagonal of the confusion matrix):

ignore_index = 3
metric = ConfusionMatrix(num_classes=3)
confmat = metric(preds, target)
confmat = confmat[:2,:2] # remove last column and row corresponding to class 3
acc = confmat.trace() / confmat.sum()

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@noamzilo
Comment options

@SkafteNicki
Comment options

Answer selected by SkafteNicki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment