You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm experiencing a runtime error when computing multiclass recall using torcheval's multiclass_recall function with average="macro". The error is:
RuntimeError: The size of tensor a (2) must match the size of tensor b (3) at non-singleton dimension 0
Steps to Reproduce:
Using the minimal example below (see the attached code), I have logits for 3 classes where only classes 0 and 2 are predicted (the argmax of each row is 0 or 2), and the ground-truth labels are all class 2. In this scenario, the true positive counts (num_tp) and the total label counts (num_labels) are computed internally. However, during the averaging step, the code seems to filter out classes with zero support from the true positives (reducing the tensor’s length, e.g., from 3 to 2) while leaving the denominator unchanged. This leads to a dimension mismatch when performing an element-wise division.
🐛 Describe the bug
I'm experiencing a runtime error when computing multiclass recall using torcheval's
multiclass_recall
function withaverage="macro"
. The error is:Steps to Reproduce:
Using the minimal example below (see the attached code), I have logits for 3 classes where only classes 0 and 2 are predicted (the
argmax
of each row is 0 or 2), and the ground-truth labels are all class 2. In this scenario, the true positive counts (num_tp
) and the total label counts (num_labels
) are computed internally. However, during the averaging step, the code seems to filter out classes with zero support from the true positives (reducing the tensor’s length, e.g., from 3 to 2) while leaving the denominator unchanged. This leads to a dimension mismatch when performing an element-wise division.MWE
Expected Behavior:
I would expect that either:
num_tp
andnum_labels
are filtered consistentlyVersions
Any guidance or fix would be greatly appreciated!
The text was updated successfully, but these errors were encountered: