Save/Load tensorflow model

What is the best way to save a tensorflow model, so I can load it fastly and easly?

tensorflow
3 votesNN138.00
1 Answers
JW234.00
2

Just use tensorflow Saver class to save the graph in checkpoints.

saver = tf.train.Saver()
# ...
with tf.Session() as sess:
  # your code here ...
  save_path = saver.save(sess, "/path/model.ckpt")
  print("Model saved in path: %s" % save_path)

and load with this way

# Add ops to save and restore all the variables.
saver = tf.train.Saver()

# Later, launch the model, use the saver to restore variables from disk, and
# do some work with the model.
with tf.Session() as sess:
  # Restore variables from disk.
  saver.restore(sess, "/path/model.ckpt")
  print("Model restored.")

Here is the doc of tensorflow https://www.tensorflow.org/guide/saved_model

Reply
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?