2016-11-09 88 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')