# Do I need to use softmax before nn.CrossEntropyLoss()?

**URL:** <https://discuss.pytorch.org/t/do-i-need-to-use-softmax-before-nn-crossentropyloss/16739>\
**Category:** Uncategorized\
**Created:** [April 20, 2018, 11:14pm UTC](https://discuss.pytorch.org/t/do-i-need-to-use-softmax-before-nn-crossentropyloss/16739 "2018-04-20T23:14:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kong](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/kong/32/4215_2.png) [@Kong](https://discuss.pytorch.org/u/Kong)\
**Post date:** [April 20, 2018, 11:14pm UTC](https://discuss.pytorch.org/t/do-i-need-to-use-softmax-before-nn-crossentropyloss/16739/1 "2018-04-20T23:14:10Z")

</div>

I am reading about the cross entropy loss [http://pytorch.org/docs/master/nn.html](http://pytorch.org/docs/master/nn.html) but I am confused. Do I need to send the output of my last layer (class scores) through a softmax function when using the nn.CrossEntropyLoss or do I just send the raw output ?

---

<div class="post-metadata">

**Author:** ![arturml](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/arturml/32/4386_2.png) [@arturml](https://discuss.pytorch.org/u/arturml)\
**Post date:** [April 21, 2018, 1:16am UTC](https://discuss.pytorch.org/t/do-i-need-to-use-softmax-before-nn-crossentropyloss/16739/2 "2018-04-21T01:16:29Z")

</div>

You just send the raw output. Check out this this thread for small discussion about this topic: [VGG output layer - no softmax?](https://discuss.pytorch.org/t/vgg-output-layer-no-softmax/9273/5)
