pytorch noob在这里,试图学习。
链接到我的笔记本:https://gist.github.com/jagadeesh-kotra/412f371632278a4d9f6cb31a33dfcfeb
我的验证准确率达到95%。
我使用以下内容来预测:
m.eval()
testset_predictions = []
for batch_id,image in enumerate(test_dataloader):
image = torch.autograd.Variable(image[0])
output = m(image)
_, predictated = torch.max(output.data,1)
for prediction in predicted:
testset_predictions.append(prediction.item())
len(testset_predictions)
问题是,当我将结果提交给参与竞争时,我只获得10%的准确率,这与随机预测一样好。我无法弄清楚我做错了什么。
请帮忙 :)
很可能是因为拼写错误;当你想使用新创建的predictated
结果时,你实际上使用predicted
:
_, predictated = torch.max(output.data,1)
for prediction in predicted:
哪个predicted
来自您之前的链接代码,它包含来自验证集而不是您的测试集的预测:
#validation
# ...
for batch_idx, (data, target) in enumerate(val_dataloader):
data, target = Variable(data), Variable(target)
output = m.forward(data)
_, predicted = torch.max(output.data,1)
所以,你甚至没有得到错误信息,因为predicted
确实存在 - 它只是你真正想要使用的...你最终提交验证集而不是测试集的结果(它肯定不会帮助两者都包含10,000个样本),因此您可以获得~10%的随机猜测准确度......