I use tf.train.Saver() in one.py file with the following code.
saver = tf.train.Saver(tf.all_variables())
saver.save(sess,"checkpoint.data")
How can I restore checkpoint.data in another python file?
I used the following code, but it didn't work.
from one import saver
import tensorflow as tf
with tf.Session() as sess:
saver.restore(sess, "checkpoint.data")
The checkpoint file (ie 'checkpoint.data'
) does not provide TensorFlow with enough information to reconstruct your model structure. In your second program, you need to reconstruct the same TensorFlow graph that was used in the first program. There are a few options for doing this:
tf.train.Saver
in each program. saver.export_meta_graph()
to write out the graph structure along with a checkpoint in your first program, and tf.train.import_meta_graph()
to import the graph structure (and create an appropriately configure tf.train.Saver
instance) in your second program.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.