报错:
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()