【发布时间】:2018-12-21 21:36:36
【问题描述】:
我需要训练一个基于序列的 10x10 图像分割。以下是我想使用的 lstm 和 convlstm 模型:
def lstmModel():
# Model definition
model = Sequential()
model.add(LSTM(50, batch_input_shape=(1, None, inp.shape[1]*inp.shape[2]), return_sequences=True, stateful=True))
model.add(Dense(out.shape[1]*out.shape[2], activation='softmax'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.summary()
return model
def convlstmModel():
# Model definition
model = Sequential()
model.add(ConvLSTM2D(12, kernel_size=5, padding = "same", batch_input_shape=(1, None, inp.shape[1], inp.shape[2], 1), return_sequences=True, stateful=True))
model.add(Conv2D(20, 3, padding='same', activation='softmax'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.summary()
return model
我为 10 个随机 10x10 图像序列的序列训练模型。 LSTM 模型对我来说似乎工作正常,但 ConvLSTM 模型显示 Conv2D 层的尺寸不匹配:
ValueError: Input 0 is incompatible with layer conv2d_1: expected ndim=4, found ndim=5
非常感谢任何帮助。谢谢!
【问题讨论】:
标签: python tensorflow keras lstm keras-layer