Skip to content

预测得分为负数 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sky-fly97 opened this issue Jul 25, 2020 · 4 comments
Open

预测得分为负数 #11

sky-fly97 opened this issue Jul 25, 2020 · 4 comments

Comments

@sky-fly97
Copy link

作者您好,我在使用您的代码训练自己的数据时,数据一共有6类,预测结果没有问题,准确率很高,但是其他的类得分为什么会出现负数呢? 并且不同的图像得分的大小程度也差很多,请问是什么原因呢

@sky-fly97
Copy link
Author

image
image
image

@sky-fly97
Copy link
Author

sky-fly97 commented Jul 25, 2020

这个是我的推理代码
`img = cv2.imread(img_dir + img_name)

img_input = img[..., ::-1] # BGR to RGB

img_input = (np.float32(img)/255.0-[0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]
img_input = img_input.transpose((2, 0, 1))
img_input = torch.from_numpy(img_input).unsqueeze(0)
img_input = img_input.type(torch.FloatTensor)
print(img_input.shape)
pred = model(img_input.cuda())
pred_score = torch.max(pred, 1)[0]
pred_index = torch.max(pred, 1)[1]`

@lxztju
Copy link
Owner

lxztju commented Jul 29, 2020

最后一层直接取出的结果没有经过softmax,可以用一个softmax得到归一化的概率值

@xsbrsg
Copy link

xsbrsg commented Jan 20, 2021

请问您测试同一张图片得出的pre值是一样的吗。我用训练的模型测试同一张图片,每次输出的pre值都有差异,想问一下您有没有出现这种情况,可能是什么原因导致的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants