【发布时间】:2019-04-01 08:58:51
【问题描述】:
这是我的代码:
from keras.layers import LSTM, Bidirectional, Dense, Input, Flatten
from keras.models import Model
input = Input(shape=(None, 100))
lstm_out = Bidirectional(LSTM(10, return_sequences=True))(input)
something = Flatten()(lstm_out)
output = Dense(22, activation='softmax')(something)
model = Model(inputs=input, outputs=output)
model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy'])
我正在构建一个具有可变输入的 LSTM
this stackoverflow question。但现在我的模型说ValueError: The shape of the input to "Flatten" is not fully defined (got (None, 20)。我该如何解决这个问题?
提前致谢
【问题讨论】:
-
如果在图创建时时间步数为
unknown,则不能应用Flatten- 最后一个Dense层有多少输入单元?
标签: python keras lstm text-classification variable-length