Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tensorflow difference between saving model via exporter and tf.train.write_graph()?

What is difference between saving a model by

  1. using exporter as specified in tensorflow serving:

eg:

from tensorflow.contrib.session_bundle import exporter
#from tensorflow_serving.session_bundle import exporter
saver = tf.train.Saver(sharded=True)
model_exporter = exporter.Exporter(saver)
model_exporter.init(
        sess.graph.as_graph_def(),
        named_graph_signatures={
            'inputs': exporter.generic_signature({'images': x}),
            'outputs': exporter.generic_signature({'scores': y})})
model_exporter.export(export_path, tf.constant(FLAGS.export_version), sess) 
  1. Using tf.train.write_graph() and tf.train.Saver() directly:

eg:

with sess.graph.as_default():
    saver = tf.train.Saver()
    saver.save(sess, path, meta_graph_suffix='meta', write_meta_graph=True)

Question is in continuation of TensorFlow saving into/loading a graph from a file

like image 829
Saurabh yadav Avatar asked Jan 19 '17 10:01

Saurabh yadav


1 Answers

Given the Exporter is now officially deprecated, the new protocol for saving graph and data is to use Saver. Here is an excellent blog with sample code: https://blog.metaflow.fr/tensorflow-how-to-freeze-a-model-and-serve-it-with-a-python-api-d4f3596b3adc.

like image 130
Hephaestus Avatar answered Oct 22 '22 06:10

Hephaestus