Keras: binary_crossentropy & categorical_crossentropy confusion
Not sure if this answers your question, but for softmax loss the output layer needs to be a probability distribution (i.e. sum to 1), for binary crossentropy loss it doesn't. Simple as that. (Binary doesn't mean that there are only 2 output classes, it just means that each output is binary.)
You are right by defining areas where each of these losses are applicable:
binary_crossentropy
(andtf.nn.sigmoid_cross_entropy_with_logits
under the hood) is for binary multi-label classification (labels are independent).categorical_crossentropy
(andtf.nn.softmax_cross_entropy_with_logits
under the hood) is for multi-class classification (classes are exclusive).
See also the detailed analysis in this question.
I'm not sure what tutorials you mean, so can't comment whether binary_crossentropy
is a good or bad choice for autoencoders.
As for the naming, it is absolutely correct and reasonable. Or do you think sigmoid
and softmax
names sound better?
So the only confusion left in your question is the categorical_crossentropy
documentation. Note that everything that has been stated is correct: the loss supports one-hot representation. This function indeed works with any probability distribution for labels (in addition to one-hot vectors) in case of tensorflow backend and it could be included into the doc, but this doesn't look critical to me. Moreover, need to check if soft classes are supported in other backends, theano and CNTK. Remember that keras tries to be minimalistic and targets for most popular use cases, so I can understand the logic here.