8

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

Saurabh yadav
  • 638
  • 6
  • 7

2 Answers2

2

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.

Hephaestus
  • 4,337
  • 5
  • 35
  • 48
0

Exporter is used after you train a model and want to serve it (use it for inference).

Saver is used for checkpointing when you train a model.

Yao Zhang
  • 5,591
  • 1
  • 16
  • 22
  • How is that different than using FreezeGraph to prepare a frozen graph for inferencing? In other words, does one need to use Exporter, if one is using freeze_graph()? – Hephaestus May 26 '17 at 19:54
  • And did this change with TF1.0+, as I see very little documentation on Exporter now. – Hephaestus May 26 '17 at 19:55
  • For example, the latest warn message (TF1.1) says this: `WARNING:tensorflow:From :17: generic_signature (from tensorflow.contrib.session_bundle.exporter) is deprecated and will be removed after 2017-06-30. Instructions for updating: Please use SavedModel instead.` – Hephaestus May 26 '17 at 20:10