Home » Android » android – Converting trained Tensorflow model to protobuf

android – Converting trained Tensorflow model to protobuf

Posted by: admin June 15, 2020 Leave a comment

Questions:

The inception net in the Android Tensorflow Demo stores the model as a protobuf file (tensorflow_inception_graph.pb). I’d like to replace this network with another one.

Is there documentation or an example somewhere on how to convert a trained TensorFlow network in Python to .pb? I’m aware of TensorFlow’s Saver but this seems to be used to save intermediate training state. Not sure how it works if the model is already trained.

How to&Answers:

tf.Graph.as_graph_def() retrieves the serialized graph. Then you just write it to a file.

Answer:

Here’s an example of saving and loading