Final Layer of Neural Network and Loss function for multilabel and Multiclass

Hello People!

I’ve just implemented a basic Pytorch model and now I want to try a model that predicts

  1. Multiclass output ie instead of just one output y_hat , it could be varying number of outputs. for eg : for a picture about the weather, it can predict [‘humid’,‘cold’,‘monsoon’] and for another just [‘hot’]

  2. Multilabel output y_hat_1 and y_hat_2

How should the final layer look like, and what loss functions should I use? I’m still working through the course and the book, so apologies if this is already in there!

Could you give more information on #2? It isn’t very clear to me.

The final layer is still a linear layer. Depending on your problem is what you do with those outputs/logits

Single Label Classification: Softmax/Cross Entropy
Multi-Label: Raw Logits/BCELossLogits

1 Like

Sure! I’m thinking we have two targets(y1 and y2), instead of one (as we generally have)

Got it. Thanks!