问题
I use a tensorflow embedding layer for a classification model like with
with tf.variable_scope('embeddings'):
word_embeddings = tf.constant(self.embedding_mat, dtype=tf.float32, name="embedding")
self.embedded_x1 = tf.nn.embedding_lookup(word_embeddings, self.x1)
self.embedded_x2 = tf.nn.embedding_lookup(word_embeddings, self.x2)
If I have a UNK token in my embedding matrix but I did not used this UNK in training, can I assign a custom vector (eg. from fasttext) during prediction? So, for this UNK word which might be similar to a trained word such that the text is classified as same class? I wonder if this is possible to cange a vector during prediction on the fly the value of the UNK vector?
How could I possibly do that?
来源:https://stackoverflow.com/questions/56045468/assign-custom-word-vector-to-unk-token-during-prediction