2016-11-18 7 views
0

私はモデルの保存と復元の方法を学びたいと思っています。私のモデルはので、ここで、少し過度に複雑であるストレートと同じエラーが発生し、コマンドラインのpythonから、MWE:このフォーマットは、ここでTensorFlowのマニュアルを参照して、以下のTensorflow保存と読み込み

import tensorflow as tf 
v1 = tf.Variable(1, name="var1") 
init_op = tf.initialize_all_variables() 
saver = tf.train.Saver() 
with tf.Session() as sess: 
    sess.run(init_op) 
    save_path = saver.save(sess, "testchk.ckpt") 
    print "model saved" 

https://www.tensorflow.org/versions/r0.11/api_docs/python/state_ops.html#Variable

エラー私は取得:

Traceback (most recent call last): 
    File "<stdin>", line 3, in <module> 
    File "/mnt/data/user/pkgs/enthought/canopy-1.5.1/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1080, in save 
self.last_checkpoints, latest_filename) 
    File "/mnt/data/user/pkgs/enthought/canopy-1.5.1/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 632, in update_checkpoint_state 
    file_io.rename(temp_pathname, coord_checkpoint_filename, overwrite=True) 
    File "/mnt/data/user/pkgs/enthought/canopy-1.5.1/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 79, in rename 
compat.as_bytes(oldname), compat.as_bytes(newname), overwrite, status) 
    File "/opt/enthought/canopy-1.5.1/appdata/canopy-1.5.1.2730.rh5-x86_64/lib/python2.7/contextlib.py", line 24, in __exit__ 
self.gen.next() 
    File "/mnt/data/user/pkgs/enthought/canopy-1.5.1/lib/python2.7/site-packages/tensorflow/python/framework/errors.py", line 450, in raise_exception_on_not_ok_status 
    pywrap_tensorflow.TF_GetCode(status)) 
tensorflow.python.framework.errors.FailedPreconditionError: checkpoint.tmp.fe418ea583db4995810d23d4ca308e3a 

このエラーを解決するにはどうすればよいですか?

+0

ファイルシステムエラーのように見えますが、パスは存在しますか?プログラムに書き込みアクセス権がありますか? – yuefengz

+0

デフォルトでは現在の作業ディレクトリだけではありませんか?はい、書き込みアクセス権があります。 – StatsSorceress

+0

絶対パスを使用してみますか? – yuefengz

答えて

0

さて、絶対パスはかなり答えはありませんでしたが、ここではうまくいきました。ターミナルで :

mkdir test_checkpoint 
python 

その後

import tensorflow as tf 
v1 = tf.Variable(1, name="var1") 
init_op = tf.initialize_all_variables() 
saver = tf.train.Saver() 
with tf.Session() as sess: 
    sess.run(init_op) 
    save_path = saver.save(sess, "./test_checkpoint/testchk.ckpt") 
    print "model saved" 

それは、物事の束を出力し、出力します:model saved

をだから私はそれが働いていると思います!以前はディレクトリが存在していたので、なぜ新しく作成したのか分かりませんが、少なくとも解決策があります。

関連する問題