2016-11-09 73 views
1

保存變量時,我試圖通過表達FailedPreconditionError在TensorFlow

saver2 = tf.train.Saver(tf.all_variables()) 
saver2.save(sess, '/home/username/learning/tensor/tffiles/ww/') 

保存的權重而保存失敗因這個錯誤:

FailedPreconditionError (see above for traceback): 
/home/username/learning/tensor/tffiles/ww/.tempstate2977384776137285958 

[[Node: save_1/save = SaveSlices[T=[DT_FLOAT, DT_FLOAT, DT_FLOAT, 
DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, 
DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"] 
(_recv_save_1/Const_0, save_1/save/tensor_names, 
save_1/save/shapes_and_slices, conv1/biases, conv1/weights, conv2/biases, 
conv2/weights, f1/_9, f2/_11, local3/biases, local3/weights, local4/biases, 
local4/weights, softmax_linear/biases, softmax_linear/weights)]] 

哪裏從何而來的錯誤?

+0

你之前初始化所有的變量? – Corentin

+1

我想到了它,但變量似乎被初始化,並且錯誤不同於'FailedPreconditionError:嘗試使用未初始化的值Variable_5',不是嗎? – cerebrou

回答

2

問題是與行,

saver2.save(sess, '/home/username/learning/tensor/tffiles/ww/') 

它缺乏CKPT文件的名稱明確指定,而應該是

saver2.save(sess, '/home/username/learning/tensor/tffiles/ww/model.ckpt')