Skip to content
Discussion options

You must be logged in to vote

@jungla88 — this was a real issue with the old unified Accuracy class but has been resolved by the task-specific API refactor. As of v1.9.0:

Use BinaryAccuracy for binary classification:

from torchmetrics.classification import BinaryAccuracy

acc = BinaryAccuracy()

preds = torch.tensor([0.4, 0.51, 0.51, 0.6, 0.7])
target = torch.tensor([0, 1, 0, 0, 1])

# Works with 1D
acc(preds, target)  # tensor(0.6000)

# Also works with extra dim — internally handled
acc(preds.unsqueeze(1), target)  # same result, no error

For spatial predictions (segmentation):

acc = BinaryAccuracy(multidim_average="global")   # flatten all spatial dims
acc = BinaryAccuracy(multidim_average="samplewise")  # per-samp…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Borda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants