更新时间:2023-12-02 12:02:10
如果要在嵌入"层上设置权重,可以将其添加到构造函数中,如下所示:
If you want to set the weights on Embedding layers you might add them to the constructor like this:
from keras.layers import Embedding
embedding_layer = Embedding(len(word_index) + 1,
EMBEDDING_DIM,
weights=[embedding_matrix],
input_length=MAX_SEQUENCE_LENGTH,
trainable=False)
https://blog .keras.io/using-pre-trained-word-embeddings-in-a-keras-model.html
稍后,您可以移交merge_ip
:
x = embedding_layer(merge_ip)