Skip to content

Commit

Permalink
Fix: JaccardIndex multi-label compute (#1125)
Browse files Browse the repository at this point in the history
(cherry picked from commit 883254e)
  • Loading branch information
KeVoyer1 authored and Borda committed Jul 22, 2022
1 parent 9e842cd commit cac8bb2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Expand Up @@ -38,6 +38,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-


### Fixed

-


- Fixed JaccardIndex multi-label compute ([#1125](https://github.com/Lightning-AI/metrics/pull/1125))



## [0.9.2] - 2022-06-29

### Fixed
Expand Down
29 changes: 22 additions & 7 deletions torchmetrics/classification/jaccard.py
Expand Up @@ -104,10 +104,25 @@ def __init__(

def compute(self) -> Tensor:
"""Computes intersection over union (IoU)"""
return _jaccard_from_confmat(
self.confmat,
self.num_classes,
self.average,
self.ignore_index,
self.absent_score,
)

if self.multilabel:
return torch.stack(
[
_jaccard_from_confmat(
confmat,
2,
self.average,
self.ignore_index,
self.absent_score,
)[1]
for confmat in self.confmat
]
)
else:
return _jaccard_from_confmat(
self.confmat,
self.num_classes,
self.average,
self.ignore_index,
self.absent_score,
)

0 comments on commit cac8bb2

Please sign in to comment.