【发布时间】:2018-11-27 17:35:53
【问题描述】:
我有一个使用 Keras 与 Conv2D 一起工作的模型,但我想添加一个 LSTM 层。这是我正在使用的数据:
- x_train 形状为 (13984, 334, 35, 1)
- y_train with shape (13984, 5)
我没有 LSTM 的模型是:
inputs = Input(name='input',shape=(334,35,1))
layer = Conv2D(64, kernel_size=3,activation='relu',data_format='channels_last')(inputs)
layer = Flatten()(layer)
predictions = Dense(5, activation='softmax')(layer)
network = Model(inputs=inputs, outputs=predictions)
network.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
在 Dense 层之前添加 LSTM 层的正确方法是什么?
我尝试使用 TimeDistributed 或 Reshape/Permute,但总是出错。
【问题讨论】:
-
你可以简单地采用reshape操作:stackoverflow.com/a/63789979/10375049
标签: python keras conv-neural-network lstm rnn