def predict_on_test(rnn, test_x):
print("Predict...")
pred_y = []
for idx in range(len(test_x)):
x = test_x[idx, :, :]
x = Variable(torch.unsqueeze(torch.Tensor(x).t(), dim=1)).cuda()
y_p = rnn(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
评论列表
文章目录