In my understanding, the formula to calculate the cross-entropy is
$$ H(p,q) = - \sum p_i \log(q_i) $$
But in PyTorch nn.CrossEntropyLoss
is calculated using this formula:
$$ loss = -\log\left( \frac{\exp(x[class])}{\sum_j \exp(x_j)} \right) $$
that I think it only addresses the $\log(q_i)$ part in the first formula.
Why does PyTorch use a different formula for the cross-entropy?