Search code examples
luastatisticstorchconfusion-matrix

Alternative to optim confusion matrix for multi label classification in torch


I have a convnet that produces multi label output. Ie: each image can be labelled with 0 to 10 labels. The output is a tensor of size 10, containing 1s (indicating a label at that index) and -1s (no label at that index). Targets are in the same format. So:

{1, 1, 1, -1, 1, 1, 1, 1, 1, 1}

Indicates labels 1-3 and 5-10. Multi label output cannot be used with the confusion matrix of the torch optim package. What are some good alternatives for evaluating prediction accuracy?

Ideally, I would like to know how accurately each label is being predicted, in terms of false positives, true positives, etc. One idea would be to make 10 separate confusion matrices and feed each the data for one index. Is there a better solution though?

Any input appreciated.


Update: the above approach worked fine, but it's cumbersome when there are many labels. I just wondered if there was a better way.


Solution

  • I made separate confusion matrices for each label, split the output predictions, and added them to the appropriate matrix. By co-plotting classification accuracy for training/validation set, it's pretty easy to interpret.