[comment] how can I get the input and output node names?
可以使用opname参数设置输入和输出节点名称。在
要列出.pbtxt文件中的节点名,请使用以下脚本。在
^{pr2}$
[comment] I found that there is a tf.estimator.Estimator.export_savedmodel(), is that the function to store model in .pb directly? And I'm struggling in it's parameter serving_input_receiver_fn. Any ideas?
import tensorflow as tf
with tf.Session() as sess:
meta_graph_def = tf.saved_model.loader.load(
sess,
[tf.saved_model.tag_constants.SERVING],
'./saved_models/1519232535')
print [n.name for n in meta_graph_def.graph_def.node]
import tensorflow as tf
from tensorflow.python.platform import gfile
with tf.Session() as sess:
with gfile.FastGFile('model.pb', 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
sess.graph.as_default()
tf.import_graph_def(graph_def, name='')
print [n.name for n in graph_def.node]
您可以使用^{} 从}
如果您使用的是^{} ,那么您将在^{} 中找到这两个文件
.ckpt
+.pbtxt
生成{是的,您必须知道您是模型的输入节点和输出节点名称。然后使用^{} 加载.pb文件并使用^{} 获得输入和输出操作
pb文件不是压缩的.ckpt文件,因此没有“压缩率”。在
但是,有一种推理方法to optimize your .pb file,这种优化可以减少文件大小,因为它删除了图形中只用于训练的部分操作(请参见完整描述here)。在
可以使用op
name
参数设置输入和输出节点名称。在要列出
^{pr2}$.pbtxt
文件中的节点名,请使用以下脚本。在export_savedmodel()
生成一个SavedModel
,这是一种用于TensorFlow模型的通用序列化格式。它应该包含与TensorFlow Serving APIs相匹配的所有内容serving_input_receiver_fn()
是生成SavedModel
所需内容的一部分,它通过向图中添加占位符来确定模型的输入签名。在从医生那里
如果您接收的是序列化的
tf.Examples
(这是一种典型模式)形式的推理请求,那么您可以使用doc中提供的示例。在这取决于它是如何产生的。在
如果是^{} 用法:
如果是^{} ,则使用:
相关问题 更多 >
编程相关推荐