Я пытаюсь внедрить предварительно встроенный слой встраивания в мою генеративную модель, используя GloVe.
В модель я добавляю последовательности из 50 (X) элементов, извлеченных из текста, и это должно предсказать 51. слово (y) в тексте.
Я достигаю точности 0,99 уже, когда модель тренировалась только для 1/100 итераций.В чем может быть проблема?
# create a weight matrix for words in training docs
embedding_matrix = zeros((vocab_size, 100))
for word, i in tokenizer.word_index.items():
embedding_vector = embeddings_index.get(word)
if embedding_vector is not None:
embedding_matrix[i] = embedding_vector
# define model
model = Sequential() #assigning the sequential function to a model
model.add(Embedding(vocab_size, 100, weights=[embedding_matrix], input_length=seq_length, trainable = False)) #defining embedding layer size
model.add(LSTM(100, return_sequences=True)) #adding layer of nodes
model.add(LSTM(100)) #adding layer of nodes
model.add(Dense(100, activation='relu')) #specifying the structure of the hidden layer, recu is an argument of a rectified linear unit.
model.add(Dense(vocab_size, activation='softmax')) #using the softmax function to creating probabilities
print(model.summary())
# compile the model
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
# fit the model
model.fit(X, y, batch_size=128, epochs=100, verbose=1)
Ссылка на github: https://github.com/KiriKoppelgaard/Generative_model коммит с 14 ноября 2018