def predict_on_test(net, test_x):
print("Predict...")
pred_y = []
for idx in range(len(test_x)):
x = test_x[idx, :]
x = Variable(torch.unsqueeze(torch.Tensor(x), dim=0)).cuda()
y_p = net(x)
_y = float(y_p.cpu().data.numpy()[0])
# print("pred %d: %f | true y: %f" % (idx, _y, test_y[idx]))
pred_y.append(_y)
return pred_y
评论列表
文章目录