【发布时间】:2019-10-01 06:22:29
【问题描述】:
更新:
无论是单词、句子还是短语,Universal Sentence Encoder 将始终返回 512 的向量大小。我想知道为什么是 512,而不是别的。
通过提供的答案解决了以下问题。
我尝试了 tensorflow 主页上提供的示例:
https://tfhub.dev/google/universal-sentence-encoder/2
我遇到这样的运行时错误:
RuntimeError: 不支持导出/导入元图 急切执行已启用。急切执行时不存在图表 已启用。
我试过的代码是:
import tensorflow.compat.v1 as tf
import tensorflow_hub as hub
config = tf.ConfigProto()
session = tf.Session(config=config)
embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder/2")
embeddings = embed(
[
"The quick brown fox jumps over the lazy dog.",
"I am a sentence for which I would like to get its embedding",
]
)
print(session.run(embeddings))
如何正确运行这段代码?
【问题讨论】:
-
这个问题不再活跃了吗?那你为什么不把它删掉。或将更新放在其顶部
标签: python tensorflow