tensorflow 模型保存后的加载路径问题

时间:2023-03-09 15:58:41
tensorflow 模型保存后的加载路径问题

import tensorflow as tf

#保存模型

saver = tf.train.Saver()

saver.save(sess, "e://code//python//test//package_test//model.ckpt", global_step=step)

#加载读取模型

with tf.Session() as sess:
new_saver=tf.train.import_meta_graph('checkout\\model.ckpt-3500.meta')
new_saver.restore(sess,"E://Code//checkout//./model.ckpt-3500")
sess.run(tf.global_variables_initializer())

按windows的常规路径("E://Code//checkout//model.ckpt-3500“)写,可能会出现异常:

Unsuccessful TensorSliceReader constructor: Failed to find any matching files for E:\Code\python\test\package_test\checkout/model.cpk