当我遇到以下问题时,我正在尝试将 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
.