checkpoint
save
[...]
saver = tf.train.Saver()
with tf.Session() as sess:
[...]
saver.save(sess, './model/lenet5')
load
[...]
saver = tf.train.Saver()
with tf.Session() as sess:
saver.restore(sess, './model/lenet5')
[...]
saver = tf.train.import_meta_graph('./model/lenet5.meta')
with tf.Session() as sess:
saver.restore(sess, './model/lenet5')
[...]
frozen_graph
save
from tensorflow.python.framework import graph_util
[...]
with tf.Session() as sess:
[...]
graph_def = tf.get_default_graph().as_graph_def()
graph_def = graph_util.convert_variables_to_constants(sess, graph_def, ['inputs', 'outputs'])
with tf.gfile.GFile('./lenet5.pb', 'wb') as f:
f.write(graph_def.SerializeToString())
load
with tf.Graph().as_default() as graph:
graph_def = tf.GraphDef()
with tf.gfile.FastGFile('./lenet5.pb', 'rb') as f:
graph_def.ParseFromString(f.read())
inputs, outputs = tf.import_graph_def(graph_def, return_elements=['inputs:0', 'outputs:0'])
with tf.Session(graph=graph) as sess:
out = sess.run(outputs, feed_dict={inputs: ...})
saved_model
save
...
load
...