Python InvalidArgumentError:索引[120,0]=3080不在[0,32][{{node embedding\u 6/embedding\u lookup}}]

Python InvalidArgumentError:索引[120,0]=3080不在[0,32][{{node embedding\u 6/embedding\u lookup}}],python,keras,nlp,lstm,Python,Keras,Nlp,Lstm,我看到其他人也提出了类似的问题,但区别在于我运行的是Keras函数API,而不是顺序模型 from keras.models import Model from keras import layers from keras import Input text_vocabulary_size = 10000 question_vocabulary_size = 10000 answer_vocabulary_size = 500 text_input = Input(shape=(None,),

我看到其他人也提出了类似的问题,但区别在于我运行的是Keras函数API,而不是顺序模型

from keras.models import Model
from keras import layers
from keras import Input
text_vocabulary_size = 10000
question_vocabulary_size = 10000
answer_vocabulary_size = 500

text_input = Input(shape=(None,), dtype='int32', name='text')
embedded_text = layers.Embedding(64, text_vocabulary_size)(text_input)
encoded_text = layers.LSTM(32)(embedded_text)
question_input = Input(shape=(None,), dtype='int32', name='question')
embedded_question = layers.Embedding( 32, question_vocabulary_size)(question_input)
encoded_question = layers.LSTM(16)(embedded_question)

concatenated = layers.concatenate([encoded_text, encoded_question],axis=-1) 

## Concatenates the encoded question and encoded text

answer = layers.Dense(answer_vocabulary_size, activation='softmax')(concatenated)
model = Model([text_input, question_input], answer)
model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['acc'])
将数据馈送到多输入模型 使用输入列表进行拟合 我在尝试拟合模型时得到的错误如下

InvalidArgumentError: indices[120,0] = 3080 is not in [0, 32)
     [[{{node embedding_6/embedding_lookup}}]]

词汇的维度是
嵌入
类的第一个参数,您可以将它们设置为第二个参数。您只需将给定的参数切换到嵌入实例。

谢谢,它可以使用层完美地工作。嵌入(text\u词汇大小,64)(text\u输入)
model.fit([text, question], answers, epochs=10, batch_size=128)
InvalidArgumentError: indices[120,0] = 3080 is not in [0, 32)
     [[{{node embedding_6/embedding_lookup}}]]