【发布时间】:2020-05-06 19:53:32
【问题描述】:
我正在尝试使用通用句子编码模型来查找句子相似性。我在本地驱动器上保存了通用句子编码器模型形式。但是我不知道如何通过代码直接从下面的本地驱动器调用它,而不是通过代码中的链接调用它。请注意,我的操作系统是 Windows。
import tensorflow as tf
import tensorflow_hub as hub
embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
def get_features(texts):
if type(texts) is str:
texts = [texts]
with tf.Session() as sess:
sess.run([tf.global_variables_initializer(), tf.tables_initializer()])
return sess.run(embed(texts))
get_features("The quick brown fox jumps over the lazy dog.I am a sentence for which I would like to get its embedding")
【问题讨论】:
标签: python tensorflow