TensorFlow RuntimeError:在 SavedModel 中找不到与标签服务关联的 MetaGraphDef [英] TensorFlow RuntimeError: MetaGraphDef associated with tags serve could not be found in SavedModel
本文介绍了TensorFlow RuntimeError:在 SavedModel 中找不到与标签服务关联的 MetaGraphDef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用 simple_save 保存模型时,当我尝试加载模型时出现运行时错误.
When I use simple_save to save a model, when I get a runtime error when I try to load the model.
要保存的代码是:
session = Session()
inputs = tf.placeholder(dtype=tf.float32, shape=(None, height, width, in_channel_size), name='input_img')
model = Some_Model(inputs, num_classes=no_of_defects, is_training=False)
logits, _ = model.build_model()
predictor = tf.nn.softmax(self.logits, name='logits_to_softmax')
feed_dict = {inputs: inputs}
prediction_probabilities = session.run(self.predictor, feed_dict=feed_dict)
tf.saved_model.simple_save(self.session, path,
inputs={"inputs" : self.inputs},
outputs={"predictor": self.predictor})
要加载的代码是:
tf.saved_model.loader.load(session, tag_constants.SERVING, path)
给出错误:
RuntimeError: MetaGraphDef associated with tags serve could not be found in SavedModel. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: `saved_model_cli`
当我跑步时
saved_model_cli show --dir path --tag_set serve --signature_def serving_default
我明白
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 512, 1024, 8)
name: input_img:0
The given SavedModel SignatureDef contains the following output(s):
outputs['predictor'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 512, 1024, 25)
name: logits_to_softmax:0
Method name is: tensorflow/serving/predict
我做错了什么?
推荐答案
问题在于加载调用.应该是:
The problem is with the load call. It should be:
tf.saved_model.loader.load(session, [tag_constants.SERVING], path)
其中 tag_constants
位于 tf.saved_model.tag_constants
.
这篇关于TensorFlow RuntimeError:在 SavedModel 中找不到与标签服务关联的 MetaGraphDef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文