仅作为记录,大佬请跳过。
神经网络的output有正有负的解决
感谢师兄的提示,在output后用softmax
print(outputs)
print(outputs.shape)
import torch.nn as nn
m=nn.Softmax(dim=1)
outputs_softmax=m(outputs)
print('outputs_softmax:',outputs_softmax)
print('outputs_softmax[0][1]',outputs_softmax[0][1])
tensor大小查看
用.shape
tensor索引
*********************
tensor的nn.softmax示例
可参考博主文章:传送门
torch.argmax
用torch.argmax(outputs_softmax,dim=1)