Hello everyone ,
I have to solve a problem where an Image is provided with multiple labels ,
There are a total 13 labels , of which each Image can be assigned to 1 or more labels .
could anyone please tell me solution for it ?
and how could I interpret loss and accuracy for such problem statement !
@MariosOreo one-hot wonât help, as âeach Image can be assigned to 1 or more labelsâ.
This is not only multi-label classification, but also multi-class, which is harder. Benchmarks which aim at solving this type of classification are for example Microsoft COCO, Open Images, PASCAL VOC, and many others.
I think you can use cross entropy as loss, to be verified.
For metrics you should check precision and recall as well as F1-score, which is the harmonic average of P and R for more stability than just taking the mean.
one-hot can help, for example:
one image raw label is [1, 3, 5]; then transform to one-hot form as [1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 , 0, 0],
outputs shape is (n, 13), then use BCEWithLogitsLoss as loss function, I think @MariosOreoâs solution is right.
That also works, but IMHO itâs a worse indicator when facing imbalanced datasets or imbalanced âhardnessâ of the classes. For example if you have a very easy class and a very hard class, youâll get a high AP for the first and low AP for the second, which average to a âmehâ AP overall. The worst case is you have many very easy classes and few very hard classes, the average will hide the very low performance on the hard classes, but maybe that hard class is very important to you and you donât know it unless you show the AP for every classâŚ