<jupyter_start><jupyter_text>Long-term predict<jupyter_code>pred = []
for tr in testX_ten[:600 - look_back]:
    pred.extend([model(tr)])
X = testX_ten[600 - look_back]
predict = model(X)
pred.extend([predict])
X = X[0]
for _ in range(len(pred), testY.size):
    X = np.append(X[1:], predict.detach().numpy())
    predict = model(torch.tensor([X]))
    pred.append(predict.detach().item())
# plt.figure(figsize=(16,8))
plt.plot(testY, label='real')
plt.plot(pred, label='LSTM')
plt.axvline(x=(600 - look_back), color='red', label='train/test split')
plt.legend(loc='best')
locs, labels = plt.xticks()
plt.xlabel('day num')
plt.ylabel('T, $^\circ$C')
labels = range(80, 800, 100)
ax = plt.axes().set_xticklabels(labels)
plt.show()
MSE(pred[-162:], testY[-162:])
torch.save(model.state_dict(), 'model')<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup