Cross-Entropy Loss in Classification Layers
2 views (last 30 days)
Show older comments
The MATLAB documentation is very clear to say that a classificationLayer computes the cross-entropy loss for problems with "mutually exclusive classes". In general, cross-entropy doesn't require mutually exclusive classes, however, and a training label does not need to be "one-hot" (i.e., a 1 in the true class component, 0 elsewhere), but can be discounted for class imbalance (see Custom Weighted Classification Layer) or can be "fuzzy", where the sum of the training label components is 1, but several components are non-zero.
In the MATLAB documents, they show what appears to be the generalized expression for cross-entropy, but they repeatedly state that the "classificationLayer" is for mutually exclusive classes only. My questions are:
1. Can anyone verify that the classificationLayer is, in fact, coded so that it will not work with fuzzy training labels? i.e., in a 2-class problem we could have a [0.8 , 0.2 ] label that works fine with cross-entropy loss as written in any cross-entropy Equation, including some equations sitting around in MATLAB documentation.
2. If MATLAB's "cross-entropy" in their classificationLayer is really only "mutually exclusive class cross-entropy", then does anyone know how to write a custom classification output layer to implement the real, general cross-entropy that can accept "fuzzy labels"? Examples such as define a Custom Classification Output Layer seem to make some sense when used in conjunction with invoking trainNetwork as "trainedNet = trainNetwork(X,Y,layers,options)", but you would have a 'FuzzyLabels' properties and the fuzzy labels would automatically get passed in from 'Y' when invoking trainNetwork if your constructor function accepted a 'fuzzyLabels' that came from 'Y' in your layers contruct? i.e., one of your layers at the end is 'GeneralCrossEntropyLayer(Y)?
Anyone get what I'm asking here, or is this just rambling nonsense?? :O :)
4 Comments
Greg Heath
on 16 Jun 2019
Edited: Greg Heath
on 16 Jun 2019
I believe I have covered this topic in both the NEWSGROUP and ANSWERS.
However, I do not have the time to find it. Try searching on variations of
greg crossentropy 65
greg cross entropy 28
crossentropy 97
cross entropy 61
Hope this helps.
Greg
Andreas
on 16 Jun 2019
An answer would consist of a link to a custom output layer that can handle a probability distribution, i.e., with cross-entropy. Have you written such a layer or seen it? Otherwise I think you have not answered the underlying premise of the question.
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!