# add export graph
def serving_input_fn():
input_ids = tf.placeholder(dtype=tf.int32, shape=[None, FLAGS.max_seq_length], name="input_ids")
input_mask = tf.placeholder(dtype=tf.int32, shape=[None, FLAGS.max_seq_length], name="input_mask")
segment_ids = tf.placeholder(dtype=tf.int32, shape=[None, FLAGS.max_seq_length], name="segment_ids")
label_ids = tf.placeholder(dtype=tf.int32, shape=[None], name="label_ids")
string_2 = tf.placeholder(dtype=tf.string, shape=[None], name="string_2")
features = {'input_ids': input_ids,
'input_mask': input_mask,
'segment_ids': segment_ids,
'label_ids': label_ids,
'string_2': string_2}
return tf.contrib.learn.InputFnOps(features, None, default_inputs=features)
export_dir = os.path.join(FLAGS.output_dir, "saved_model")
estimator.export_savedmodel(export_dir, serving_input_fn(),
assets_extra={"vocab.txt": FLAGS.vocab_file},
as_text=False,
strip_default_attrs=True)
Tensorboard estimator export_savedmodel简单用法
最新推荐文章于 2025-09-11 05:45:36 发布
本文详细介绍如何使用TensorFlow定义输入占位符,构建输入函数,并通过estimator.export_savedmodel方法将模型导出为SavedModel格式,便于后续的模型部署与服务化。同时,文章还涉及了模型导出过程中的一些关键参数设置,如词汇表文件的额外资产添加等。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.9
TensorFlow
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型
593





