Optimization-AI / LibAUC

LibAUC: A Deep Learning Library for X-Risk Optimization
https://libauc.org/
MIT License
273 stars 37 forks source link

Using AUCM_MultiLabel for multi-class classification but found the loss returns 0 #31

Closed ynyang94 closed 1 year ago

ynyang94 commented 1 year ago

Hi, I'm using your library for our project. Our project basically need to classify the images into 6 classes. So I'm trying to use AUCM_MultiLabel for this task. The argument I input is the true label (value from 0 to 5), and the estimated index (discrete value from 0 to 5). But it always return 0. When I trying to use the raw estimate inputting into this function, meaning the 6x1 tensor from the model with the true label. It always give me error on tensor dimension, which should be equal to 1. Could you help figure where I'm wrong? or where I didn't understand? Thanks a lot!

yzhuoning commented 1 year ago

Hi Yufeng,

To use AUCM_MultiLabel, your prediction and label tensors need to be reshaped into (B, C), where B is the batch size and C is the number of classes in your dataset. If your labels tensor is in either (B,) or (B, 1) format, it will not be compatible with the current multi-label loss. In other words, you can convert your label tensors to one-hot format (B, C) and change the number of classes for your model output to C. This should work with the AUCM_MultiLabel loss.