'binary_crossentropy' & 'categorical_crossentropy' in keras

In model.compile(*) of keras, I met binary_crossentropy & categorical_crossentropy. These two kinds of loss somehow made me confused.
Checking their underlying will reveal the mechanism of these two kinds of loss.

lossrefer to
binary_crossentropyK.mean(K.binary_crossentropy(y_true, y_pred), axis=-1)
categorical_crossentropytf.nn.softmax_cross_entropy_with_logits(labels=target, logits=output)

The problem is what is binary_crossentropy and softmax_cross_entropy_with_logits in TensorFlow.

binary_crossentropy (and tf.nn.sigmoid_cross_entropy_with_logits under the hood) is for binary multi-label classification (labels are independent).
categorical_crossentropy (and tf.nn.softmax_cross_entropy_with_logits under the hood) is for multi-class classification (classes are exclusive).

ref:
python - Keras: binary_crossentropy & categorical_crossentropy confusion - Stack Overflow
https://stackoverflow.com/questions/47877083/keras-binary-crossentropy-categorical-crossentropy-confusion

posted on 2018-08-05 13:08  yusisc  阅读(1)  评论(0编辑  收藏  举报

导航