Loss function for multi-label classification
Multi-label classification, tasks commonly be seen on health record data (multi symptoms).
Loss function design:
Multi binary cross-entropy
each class has a binary outputLabel smoothing, another regularization technique
It’s designed to make the model a little bit less certain of it’s decision by changing a little bit its target: instead of wanting to predict 1 for the correct class and 0 for all the others, we ask it to predict 1-ε for the correct class and ε for all the others, with ε a (small) positive number and N the number of classes. This can be written as:
$$ \text {loss}=(1-\varepsilon) c e(i)+\varepsilon \sum c e(j) / N $$
where ce(x) is cross-entropy of x (i.e. −log(px)), and i is the correct class.
finally, for multi-label loss function:
$$ (1-\epsilon) \sum_{i}\left(-\frac{\log p_{i}}{n}\right)+\frac{\epsilon}{N} \sum\left(-\log p_{i}\right) $$
See the fastai implementation here: LabelSmoothingCrossEntropy
about line 285:
|
|