Hello Hüseyin!



 Huseyin:

This means that instead of computing n binary classification, I should have two branches (two output layer), where one computes the multilabel output loss and the other branch computes the single binary output loss.


I think what you propose is correct, but I wouldn’t say it quite this
way.
Let’s say you have nClass classes, and you want to perform both
single-label and multi-label multi-class classification.
In order to have two “branches” you could have a final Linear layer
with 2 * nClass outputs.  The first nClass of those would be your
single-label branch, and would be fed into CrossEntropyLoss with
a single integer class label (per sample in your batch) as the target
for CrossEntropyLoss.
The second set of nClass output values would be your multi-label
branch, and would be fed into BCEWithLogitsLoss with a set
nClass per-class probabilities (which could just be 0.0 and 1.0
labels) as the target for BCEWithLogitsLoss.


Then combining the both loss will get me the total loss.


Yes, then sum the two losses together to get your total_loss, call
total_loss.backward(), and optimize as usual.
You will likely want to perform a weighted sum of your two losses to
balance the relative performance of your two types of classification,
as dictated by your specific needs.
Good luck.
K. Frank