【bug】torch.nn.Softmax()报错.UserWarning: Implicit dimension choice for softmax has been deprecated

报错:

C:\Users\ting\anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\container.py:204: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  input = module(inpuz

修改:

翻译一下,就是说用户警告:已弃用softmax的隐式尺寸选择。将调用更改为包含dim=X作为参数。 

nn.Softmax() 改成 nn.Softmax(dim=1)  ,即在第1维上概率sum=1


dim的数值可以根据自己的需要更改。

torch.nn.Softmax(dim=1)可参考这篇文章,有图,挺清晰 Pytorch小记-torch.nn.Softmax(dim=1)

猜你喜欢

转载自blog.csdn.net/m0_70813473/article/details/130218412