My model is:
model = Sequential()
model.add(Embedding(input_dim=vocab_size,
output_dim=1024, input_length=self.SEQ_LENGTH))
model.add(LSTM(vocab_size))
model.add(Dropout(rate=0.5))
model.add(Dense(vocab_size - 1, activation='softmax'))
And I have it trained. But now during inference time, how can I use that embedding?
Your question is solved here . As skeleton you can use this code:
from tensorflow.python.keras.preprocessing.text import Tokenizer
tokenizer_obj = Tokenizer()
tokenizer_obj.fit_on_texts(your_dataset)
...
max_length = max_number_words
X_test_tokens = tokenizer_obj.texts_to_sequences(X_test)
X_test_pad = pad_sequences(X_test_tokens, maxlen=max_length, padding='post')
score, acc = model.evaluate(X_test_pad, y_test, batch_size=128)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.