Are there any examples for multi label classification

are there any examples for multi label classification ?

I think there are no Multi Label Classification examples at the moment. However, going from a multi class classification to a multi label classification is pretty simple:

  1. Use a multi-hot encoding instead of a one-hot encoding for the labels
  2. Use sigmoid instead of softmax activations on the output layer
  3. Use an appropriate loss function for your task, you could try something like MultiLabelLoss

For other ways of doing it, see https://en.wikipedia.org/wiki/Multi-label_classification#Problem_transformation_methods.

thank you , let me try

If each ‘label’ has multi-class instead of binary-class, i suppose it must use multi-output with MCXENT LossFunction on each output. Am i right ?
For example, to classify 5 kinds of food (5 labels) that each food has 1 of 7 colors (class of label), then there are 5 outputs for the model, and each output is corresponding to ont-hot of 8 values (value 0 for not that label, value 1~7 for the 7 colors).

In that case, yes - you would use ComputationGraph with multiple output layers.
The first output layer would have nOut(5) + softmax + MCXENT
The second output layer would have nOut(8) + softmax + MCXENT

1 Like

hi treo,
here is my code : https://github.com/blackwingf/multilabel
TextCNN4MultiIntentCommand is modified from CnnSentenceClassificationExample according to your advice .
The code of multi-hot representation locates in MultiLabelSentenceIterator Line 340.
The final prediction seems ok.
Am I right?