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()

上一篇:Next.js报错the ‘url‘ property is deprecated


下一篇:ITMS-90809: Deprecated API Usage