Multiclass-multioutput classification with different number of classes

As described in this documentation, multiclass-multioutput classification is a classification task which labels each sample with a set of non-binary properties.

In the example provided, each sample has two labels, one for type of fruit (label 1) and the other for the color of the fruit (label 2).

Based on the description, this classification must cover the case where label 1 has x possibilities and label 2 has y possibilities where x and y are different.

If I were to set this up with PyTorch,

  1. How should the output/labels be formatted?
  2. What would be proper loss function

Thanks

I don’t think a combined loss function is necessarily needed and would probably see both tasks independently using different model outputs (with a shared “root” model) and with an own criterion.
E.g. you could create two different “heads” (e.g. classification layers) while reusing the same feature extractor, return the logits for both tasks separately and train the model using both losses.