What loss function should I use for multi-labeling without one-hot

Hi, I have a category of 14 classes.
I have 8 samples, so the output tensor is [8, 14].
I have three labels for each sample, so my target label tensor is [8,3].
What loss function should I use for this multi-labeling problem without transferring the target label to one-hot? Thanks!

1 Like

Hi sky1ove,

For multiclass classification problems, you’ll generally use Binary Cross Entropy Loss (BCELoss). This does require targets to be one-hot encoded though. As far as I know, for multiclass classification problems, you’ll generally need to one-hot encode your targets.

Normal Cross Entropy Loss assumes only 1 label per example, which makes it unsuitable for multiclass classification problems.

Here is a quick screenshot of a notebook I made showing using BCELoss:

Let me know if this is helpful or if you have other questions.

1 Like

This is a great example. Thank you so much!

1 Like