LSTM时间序列预测 python代码——import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
tf.reset_default_graph()
#——————————————————导入数据——————————————————————
#读入数据
data = pd.read_excel(r'C:\Users\10025\Desktop\完整数据.xls')
data = data.values
#定义常量
rnn_unit=10 #hidden layer units
input_size=3 #数据输入维度
output_size=1 #数据输出入维度
lr=0.0006 #学习率
#获取训练集
def get_train_data(batch_size=60,time_step=20,train_begin=0,train_end=5800):#用前5800个数据作为训练样本
batch_index=[]
data_train=data[train_begin:train_end]
normalized_train_data=(data_train-np.mean(data_train,axis=0))/np.std(data_train,axis=0) #标准化
train_x,train_y=[],[] #训练集
for i in range(len(normalized_train_data)-time_step):
if i % batch_size==0:
1