-
Notifications
You must be signed in to change notification settings - Fork 299
Description
I converted tensorflow pb file to onnx, load onnx to tf and export the graph to a new pb file. But when load the pb file in tensorflow, it failed.
with tf.Session(graph=tf.Graph()) as sess:
... tf.saved_model.load(sess,export_dir='/tmp/pbdir/',tags=['serve'])
...
Traceback (most recent call last):
File "", line 2, in
File "/opt/anaconda3/envs/dlipy3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 324, in new_func
return func(*args, **kwargs)
File "/opt/anaconda3/envs/dlipy3/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 269, in load
return loader.load(sess, tags, import_scope, **saver_kwargs)
File "/opt/anaconda3/envs/dlipy3/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 422, in load
**saver_kwargs)
File "/opt/anaconda3/envs/dlipy3/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 349, in load_graph
meta_graph_def = self.get_meta_graph_def_from_tags(tags)
File "/opt/anaconda3/envs/dlipy3/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 327, in get_meta_graph_def_from_tags
"\navailable_tags: " + str(available_tags))
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
available_tags: []
There's no any tags in the new pb file.
Use saved_model_cli to check tag-sets in saved model, there's no any tag.
(dlipy3) [root@haswell01 tmp]# saved_model_cli show --dir /tmp/pbdir/ --all
2019-09-02 04:58:42.332050: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudart.so.10.1
(dlipy3) [root@haswell01 tmp]#
The original pb file save by tensorflow model have 'serve' tag.
(dlipy3) [root@haswell01 tmp]# saved_model_cli show --dir /dlfs/chudg/onnx/tutorials/tutorials/assets/output/saved_model --all
2019-09-02 04:46:45.606824: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudart.so.10.1
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['input/input:0'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 784)
name: input/input:0
The given SavedModel SignatureDef contains the following output(s):
outputs['output/result:0'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 10)
name: output/result:0
Method name is: tensorflow/serving/predict
(dlipy3) [root@haswell01 tmp]#
The purpose I convert tf pb-->onnx--> tf pb is do some pruning of onnx and use tensorflow to re-train the model. Anyone can help?