版权声明:本文为博主原创文章,保留著作权,未经博主允许不得转载。 https://blog.csdn.net/LoseInVain/article/details/82916163
- pytorch的交叉熵
nn.CrossEntropyLoss
在训练阶段,里面是内置了softmax
操作的,因此只需要喂入原始的数据结果即可,不需要在之前再添加softmax
层。这个和tensorflow的tf.softmax_cross_entropy_with_logits
如出一辙.[1][2]
Reference
[1]. Why does CrossEntropyLoss include the softmax function?
[2]. Do I need to use softmax before nn.CrossEntropyLoss()?