【发布时间】:2019-06-07 22:04:25
【问题描述】:
当我遇到以下问题时,我正在尝试将 tf_hub 用于universal-sentence-encoder-large:
FailedPreconditionError (see above for traceback): Table not initialized.
TensorFlow好像认为我没有运行init op,但实际上,我已经运行了init op:
embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
embeddings = embed([
"The quick brown fox jumps over the lazy dog."])
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
embeddings = sess.run(embeddings)
print(embeddings)
相同的代码结构也适用于其他 tf_hub 模型,例如 elmo。
【问题讨论】: