【问题标题】:Python Keras Sequential model inputPython Keras 序列模型输入
【发布时间】:2021-05-24 00:00:00
【问题描述】:

我有一个数组用于尝试使用 tf.Keras 进行一些 times series sliding window method for machine learning 预测:

X.shape

(8779, 6, 1)

适应 MLP 模型:

# define model
model = Sequential()
model.add(Dense(100, activation='relu', input_shape=(6,)))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mse')

谁能给我一个关于如何纠正这个模型输入的提示?

input_shape=(6,)

我不知道如何克服这个错误:

ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 6 but received input with shape (None, 6, 1)

【问题讨论】:

  • 我认为你需要设置input_shape=6 而不是input=(6,)
  • 更改为input_shape=(6,1)
  • @Andrey 谢谢你的工作

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


【解决方案1】:

即使它是通过 cmets 的建议解决的,这里是解决方案:

变化:

input_shape=(6,)

进入:

input_shape=(6,1)

工作。

【讨论】:

    猜你喜欢
    • 2018-03-16
    • 2019-12-12
    • 2017-12-24
    • 2021-02-27
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多