x_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 1))和trainX_input = np.reshape(trainX, (trainX.shape[0], 1, trainX.shape[1]))
对于keras,数据是reshape成[samples, steps, features], X_train.shape[0]表示有几行样本----samples X_train.shape[1]表示有几列样本,就是当时划分时候的步数----steps 对于单变量的预测,也就是一列X,特征就是1 所以,应该用x_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 1))
资料: