-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accuracy metric computing doesn't ignore "ignore index" #1209
Comments
@jiehuang165 I have the same issue and agree with you. In the function 'losses' in the decode_head.py, other losses like loss_decode receives the ignore_index as input, but accuracy does not. if not isinstance(self.loss_decode, nn.ModuleList):
losses_decode = [self.loss_decode]
else:
losses_decode = self.loss_decode
for loss_decode in losses_decode:
if loss_decode.loss_name not in loss:
loss[loss_decode.loss_name] = loss_decode(
seg_logit,
seg_label,
weight=seg_weight,
ignore_index=self.ignore_index)
else:
loss[loss_decode.loss_name] += loss_decode(
seg_logit,
seg_label,
weight=seg_weight,
ignore_index=self.ignore_index)
loss['acc_seg'] = accuracy(seg_logit, seg_label)
return loss |
I have puzzled by this problem...
|
thank you. |
solved |
wjkim81
pushed a commit
to wjkim81/mmsegmentation
that referenced
this issue
Dec 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Shouldn't "ignore_index" be ignored when computing accuracy?
Model training will calculate "acc_seg" when computing loss.
mmsegmentation/mmseg/models/decode_heads/decode_head.py
Line 264 in ba52d50
It calls accuracy funciton
mmsegmentation/mmseg/models/losses/accuracy.py
Line 5 in ba52d50
and the accuracy metric is calculated as
mmsegmentation/mmseg/models/losses/accuracy.py
Line 49 in ba52d50
However, the denominator
target.numel()
includes areas with ignore_index. I mean accuracy=(num of correct) / (all num without ignore). Ignore samples should not present in both numerator and denominator, right? The above implementation causes the accuracy metric to be lower than expected. I think maybe the correct codes are:The text was updated successfully, but these errors were encountered: