# Does NLLLoss handle Log-Softmax and Softmax in the same way?

**URL:** <https://discuss.pytorch.org/t/does-nllloss-handle-log-softmax-and-softmax-in-the-same-way/8835>\
**Category:** Uncategorized\
**Created:** [October 19, 2017, 3:34am UTC](https://discuss.pytorch.org/t/does-nllloss-handle-log-softmax-and-softmax-in-the-same-way/8835 "2017-10-19T03:34:41Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [January 10, 2020, 2:40am UTC](https://discuss.pytorch.org/t/does-nllloss-handle-log-softmax-and-softmax-in-the-same-way/8835/8 "2020-01-10T02:40:54Z")

</div>

The formula in the docs is the negative log softmax written as:

```python
- log ( exp(x[class]) / sum(exp(x[j]))

```

`x` are the logits here while `exp()/sum(exp())` is the softmax function.

---

_[View the full topic](https://discuss.pytorch.org/t/does-nllloss-handle-log-softmax-and-softmax-in-the-same-way/8835)._
