InvalidArgumentError: indexes[120,0] = 3080 отсутствует в [0, 32) [[{{node embedding_6/embedding_lookup}}]] ⇐ Python

Программы на Python
Anonymous
InvalidArgumentError: indexes[120,0] = 3080 отсутствует в [0, 32) [[{{node embedding_6/embedding_lookup}}]]

Сообщение Anonymous »

Я видел, как другие задавали подобные вопросы. Но разница в том, что я использую Keras Functional 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'])


Передача данных в модель с несколькими входами

import numpy as np
num_samples = 1000
max_length = 100

text = np.random.randint(1, text_vocabulary_size, size=(num_samples, max_length))

question = np.random.randint(1, question_vocabulary_size, size=(num_samples, max_length))

answers = np.random.randint(0, 1, size=(num_samples, answer_vocabulary_size))


Подбор с использованием списка входных данных

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}}]]


Подробнее здесь: https://stackoverflow.com/questions/590 ... -embedding

Вернуться в «Python»