【问题标题】:How to fit 2D pandas array into Keras LSTM layer?如何将 2D 熊猫数组放入 Keras LSTM 层?
【发布时间】:2018-09-29 11:32:24
【问题描述】:

我有一个二维数组(熊猫),它是时间序列,有 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])))

this 中所建议的那样。但是错误出现了,

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

【问题讨论】:

    标签: python machine-learning keras time-series lstm


    【解决方案1】:

    LSTM 需要一个 3D 数组作为输入,因此 input_shape 形状的长度应为 2...

    假设X_train.shape(3180, 8, 1),这应该可以:

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

    【讨论】:

    • 请告诉我,我们如何提高任何进行时间序列预测的 Keras+LSTM 网络的准确性。
    • 如果这解决了您的问题,请选择正确的答案。关于准确性,您可能应该提出一个新问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-12
    • 2018-02-22
    相关资源
    最近更新 更多