Is 'ignore_index=0' necessary for binary classification? #503
Replies: 2 comments 3 replies
-
|
Hi @dakomura, |
Beta Was this translation helpful? Give feedback.
-
|
@geografif to close the loop here — the original advice to use You do NOT need
The correct setup for binary segmentation (v1.9.0): from torchmetrics.classification import BinaryJaccardIndex
# preds: (N, H, W) — 0 or 1
# target: (N, H, W) — 0 or 1
iou = BinaryJaccardIndex()
score = iou(preds, target)No from torchmetrics.classification import MulticlassJaccardIndex
iou = MulticlassJaccardIndex(num_classes=2, average="none")
per_class = iou(preds, target) # tensor([iou_bg, iou_fg])When you WOULD use Docs: JaccardIndex |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to use the IoU metric for the binary segmentation task (background or target).
The prediction matrix has only one channel for the target class (not 2 channels for background and target class).
The current code is as follows.
Do I need to add 'ignore_index=0' when I'm only interested in the target class?
Beta Was this translation helpful? Give feedback.
All reactions