Skip to content

Commit

Permalink
proper mean calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Isalia20 committed Jan 3, 2025
1 parent 998a2bc commit b67a5b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/torchmetrics/functional/segmentation/mean_iou.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ def mean_iou(
score = _mean_iou_compute(intersection, union)
valid_classes = union > 0
score = score * valid_classes
return score if per_class else score[valid_classes].mean(dim=-1)
return score if per_class else score.sum(dim=-1) / valid_classes.sum(dim=-1)

0 comments on commit b67a5b6

Please sign in to comment.