UserWarning:Implicit dimension choice for softmax has been deprecated. 消除警告的办法

版权声明:转载注明出处 https://blog.csdn.net/york1996/article/details/84191229

UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  input = module(input)

这个警告的原因是softmax()函数已经被弃用了,虽然程序还是可以运行成功,但是这个做法不被pytorch所赞成。这个写法在早期的pytorch版本是没有警告的,现在因为其他考虑,要加上有指明dim参数。

nn.Softmax()

改成

nn.Softmax(dim=1)

dim=某个数字,这个数字可以根据自己的需要更改。

猜你喜欢

转载自blog.csdn.net/york1996/article/details/84191229
今日推荐