# Why are there two versions of softmax cross entropy? Which one to use in what situation?

I have seen 2 forms of softmax cross-entropy loss and are confused by the two. Which one is the right one? For example in this Quora answer, there are 2 answers:

1. $$L(\mathbf{w})=\frac{1}{N} \sum_{n=1}^{N} H\left(p_{n}, q_{n}\right)=-\frac{1}{N} \sum_{n=1}^{N}\left[y_{n} \log \hat{y}_{n}+\left(1-y_{n}\right) \log \left(1-\hat{y}_{n}\right)\right]$$

2. $$\mathrm{L}(y, \hat{y})=-\Sigma y(i) \log \hat{y}(i)$$, which is only the first part of the version one.

In the first case there is only one output, if you had two outputs it would have been $$$$-\frac{1}{N} \sum_{n=1}^N \sum_{j=1}^2 y_{n,j} \log(\hat y_{n,j})$$$$ where $$n$$ iterates over batch samples, and $$j$$ over two classes. The reason why it was written like that is that if you have two classes you can have only one output because you can immediately conclude about probability of the second class if you have the probability of the first class, it would simply be $$p_1 = 1-p_0$$.
In the second case, with batch samples included, it would be $$$$-\frac{1}{N} \sum_{n=1}^N \sum_{j=1}^c y_{n,j} \log(\hat y_{n,j})$$$$ wheren $$n$$ iterates over batch samples, and $$j$$ over $$c$$ output classes.