Python 如何将2D pandas阵列适配到Keras LSTM层?

Python 如何将2D pandas阵列适配到Keras LSTM层?,python,machine-learning,keras,time-series,lstm,Python,Machine Learning,Keras,Time Series,Lstm,我有一个二维数组(熊猫),它是一个时间序列,有3180行,每行有8列(数组)作为特征。我正在尝试训练一个LSTM层 sc = StandardScaler() X_train = sc.fit_transform(X_train) print (X_train.shape) classifier = Sequential() classifier.add(LSTM(units=128, input_shape=(1, len(X_train), x.shape[1]))) 如中所述。但是错误就

我有一个二维数组(熊猫),它是一个时间序列,有3180行,每行有8列(数组)作为特征。我正在尝试训练一个LSTM层

sc = StandardScaler()
X_train = sc.fit_transform(X_train)
print (X_train.shape)
classifier = Sequential()
classifier.add(LSTM(units=128, input_shape=(1, len(X_train), x.shape[1])))
如中所述。但是错误就像

ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4

LSTM
需要一个3D数组作为输入,因此
input\u shape
shape的长度应为2

假设
X\u train.shape
(3180,8,1)
,这应该可以工作:

LSTM(units=128, input_shape=X_train.shape[1:]))

请让我知道,我们如何提高进行时间序列预测的任何Keras+LSTM网络的准确性。如果这解决了您的问题,请选择正确答案。关于准确性,您可能应该开始一个新问题。