6
我已經寫了一個張量流CNN,它已經被訓練了。我想恢復它在幾樣,但不幸的是它吐出運行:Tensorflow ValueError:沒有要保存的變量
ValueError: No variables to save
我的eval代碼可以在這裏找到:
import tensorflow as tf
import main
import Process
import Input
eval_dir = "/Users/Zanhuang/Desktop/NNP/model.ckpt-30"
checkpoint_dir = "/Users/Zanhuang/Desktop/NNP/checkpoint"
init_op = tf.initialize_all_variables()
saver = tf.train.Saver()
def evaluate():
with tf.Graph().as_default() as g:
sess.run(init_op)
ckpt = tf.train.get_checkpoint_state(checkpoint_dir)
saver.restore(sess, eval_dir)
images, labels = Process.eval_inputs(eval_data = eval_data)
forward_propgation_results = Process.forward_propagation(images)
top_k_op = tf.nn.in_top_k(forward_propgation_results, labels, 1)
print(top_k_op)
def main(argv=None):
evaluate()
if __name__ == '__main__':
tf.app.run()
非常感謝你,雖然我沒有刪除EVAL數據= EVAL數據,它應該仍然工作。現在當我運行程序時,python不會輸出任何內容。 –
我不確定'eval_data'來自哪裏,因爲該名稱在您的示例中未被綁定。 Process.eval_inputs()是否使用輸入管道?也許你需要在運行'saver.restore()'後添加'tf.train.start_queue_runners(sess = sess)。 – mrry
謝謝。代碼是固定的,但添加該行後彈出新的錯誤。 E tensorflow/core/client/tensor_c_api.cc:485] targets [0]超出範圍 –