We proceed as follows:
- To use the saver class, first an object of this class is created:
saver = tf.train.Saver()
- The simplest way to save all the variables in a graph is to call the save() method with the following two parameters: the session object and the path to the file on the disk where the variables will be saved:
with tf.Session() as tfs: ... saver.save(tfs,"saved-models/model.ckpt")
- To restore the variables, the restore() method is called:
with tf.Session() as tfs: saver.restore(tfs,"saved-models/model.ckpt") ...
- Let us revisit the example from Chapter 1, TensorFlow 101, the code to save the variables in the graph in the simple example is as follows:
# Assume ...