【发布时间】:2019-02-06 05:30:56
【问题描述】:
我已经看到并尝试了两种方法,但无法理解它有什么不同。以下是我使用的两种方法:
方法一:
saver = tf.train.import_meta_graph(tf.train.latest_checkpoint(model_path)+".meta")
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(tf.local_variables_initializer())
if(tf.train.checkpoint_exists(tf.train.latest_checkpoint(model_path))):
saver.restore(sess, tf.train.latest_checkpoint(model_path))
print(tf.train.latest_checkpoint(model_path) + "Session Loaded for Testing")
方法二:
saver = tf.train.Saver()
sess =tf.Session()
sess.run(tf.global_variables_initializer())
if(tf.train.checkpoint_exists(tf.train.latest_checkpoint(model_path))):
saver.restore(sess, tf.train.latest_checkpoint(model_path))
print(tf.train.latest_checkpoint(model_path) + "Session Loaded for Testing")
我想知道的是:
以上两种方法有什么区别?
加载模型的最佳方法是什么?
请让我知道您对此有何建议。
【问题讨论】:
标签: python python-3.x tensorflow model