保存模型有什么区别
使用tensorflow服务中指定的exporter:
例如:
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)
直接使用tf.train.write_graph()和tf.train.Saver():
例如:
with sess.graph.as_default(): saver = tf.train.Saver() saver.save(sess, path, meta_graph_suffix='meta', write_meta_graph=True)
问题是继续TensorFlow从文件中保存/加载图形