【发布时间】:2019-07-14 01:04:10
【问题描述】:
我正在使用以下命令使用通用句子编码器预训练模型:
import tensorflow as tf
import tensorflow_hub as hub
MODEL_NAME = 'tf-sentence-encoder'
VERSION = 1
SERVE_PATH = './models/{}/{}'.format(MODEL_NAME, VERSION)
with tf.Graph().as_default():
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
text = tf.placeholder(tf.string, [None])
embedding = module(text)
init_op = tf.group([tf.global_variables_initializer(),
tf.tables_initializer()]
)
with tf.Session() as session:
session.run(init_op)
tf.saved_model.simple_save(session, SERVE_PATH,
inputs = {"text": text}, outputs = {"embedding": embedding},
legacy_init_op = tf.tables_initializer()
)
如何为 RESTFUL API 重新加载保存的模型?
【问题讨论】:
-
您已经使用 tensorflow-hub 来构建模型,但我认为您的问题通常是关于 tensorflow 的。 (哪些 RESTFUL API?可能是 tensorflow-serving?)
标签: python-3.x tensorflow tensorflow-serving tensorflow-hub