【问题标题】:ValueError: Input 0 of layer lstm_12 is incompatible with the layer: expected ndim=3, found ndim=4ValueError: 层 lstm_12 的输入 0 与层不兼容:预期 ndim=3,发现 ndim=4
【发布时间】:2022-01-06 21:24:51
【问题描述】:
我正在研究 seq2seq 模型,我想使用Keras Blog Bonus FAQ 中给出的嵌入层。这是我的代码,其中 num_encoder_tokens 是 67,num_decoder_tokens 是 11。
我遇到了如图所示的问题。
谁能帮我重塑嵌入层的输出形状或 LSTM 的输入形状,因为我不知道该怎么做。
【问题讨论】:
标签:
python
tensorflow
keras
lstm
seq2seq
【解决方案1】:
您的输入应该是:
encoder_inputs = keras.Input(shape=(None,))
和
decoder_inputs = keras.Input(shape=(None,))
这将允许您拥有可变的输入长度。