《临时笔记》用pytorch踩过的坑

版权声明:本文为博主原创文章,保留著作权,未经博主允许不得转载。 https://blog.csdn.net/LoseInVain/article/details/82916163
  1. 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()?

猜你喜欢

转载自blog.csdn.net/LoseInVain/article/details/82916163
今日推荐