TF save/restore graph fails at tf.GraphDef.ParseFromString()

前端 未结 3 1440
闹比i
闹比i 2020-12-19 05:15

Based on this converting-trained-tensorflow-model-to-protobuf I am trying to save/restore TF graph without success.

Here is saver:



        
3条回答
  •  温柔的废话
    2020-12-19 05:56

    The GraphDef.ParseFromString() method (and, in general, the ParseFromString() method on any Python protobuf wrapper) expects a string in the binary protocol buffer format. If you pass as_text=False to tf.train.write_graph(), then the file will be in the appropriate format.

    Otherwise you can do the following to read the text-based format:

    from google.protobuf import text_format
    # ...
    graph_def = tf.GraphDef()
    text_format.Merge(proto_b, graph_def) 
    

提交回复
热议问题