首页 > 其他分享> > UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include d
UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include d
作者:互联网
报错:
UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
probs = F.softmax(output.cpu()).detach().numpy()[0]
(我的F是import torch.nn.functional as F)
这个要区别清楚torch.nn.Softmax()和torch.nn.functional.softmax()的不同使用方法。可以参考链接:https://blog.csdn.net/m0_46653437/article/details/111610571?
解决方案:
把probs = F.softmax(output.cpu()).detach().numpy()[0]
修改为probs = F.softmax(output.cpu(), dim=1).detach().numpy()
标签:detach,nn,deprecated,torch,UserWarning,softmax,include,numpy,probs 来源: https://blog.csdn.net/qq_45128278/article/details/116028914