Pytorch之CrossEntropyLoss() 与 NLLLoss() 的区别

CrossEntropyLoss()

输入:未做过softmax的预测结果(如(batch,class,h, w))

          未做one-hot 的真实标签

执行:其内部先做softmax,再取log,最后取负。

NLLLoss() 

输入:做过logsoftmax的预测结果

           未做one-hot 的真实标签

执行:其内部直接取负。

发布了38 篇原创文章 · 获赞 98 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/xijuezhu8128/article/details/86594559