< Tensorflow > Softmax cross entropy & Sigmoid cross entropy
How difference
For multi-class classification, if you want optimize only one category during training, you should use SOFTMAX cross entropy. Otherwise, if you want to optimize more than one category, you should use SIGMOID cross entropy.
The code below could demonstrate
1 | from __future__ import absolute_import |
The results are as follows:
1 | loss1: 0.021537079509314265 |
loss1 is the result which is computed through naive implementation of sigmoid cross entropy.
loss2 is the result which is computed through the standard sigmoid cross entropy in tensorflow API.
loss4 is the result which is computed through naive implementation of softmax cross entropy.
loss5 is the result which is computed through the standard sigmoid cross entropy in tensorflow API.
As you can see, the result of sigmoid cross entropy and softmax cross entropy are the same.
This is mainly because sigmoid could be seen a special case of sofmax. To sigmoid one number could equal to softmax two number which could sum to that number.
< Tensorflow > Softmax cross entropy & Sigmoid cross entropy
https://zhengtq.github.io/2019/01/03/softmax-sigmoid-cross-entropy/