チェックポイントファイルとイベントログをhdfsに直接書き込むためにsaver.saveとFileWriter関数を使用できますか?
私は自分のコードを実行します。私は、ローカルパスにhdfs_pathを交換するときファイル "test_hdfs.py"、save_path = saver.save(sess、hdfs_path + "save_net.ckpt") "{}の親ディレクトリが存在しないため、保存できません"
W = tf.Variable([[1,2,3],[3,4,5]], dtype=tf.float32, name='weights')
b = tf.Variable([[1,2,3]], dtype=tf.float32, name='biases')
init = tf.global_variables_initializer()
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(init)
save_path = saver.save(sess, hdfs_path+"save_net.ckpt")
print("Save to path: ", hdfs_path)
は、それは大丈夫実行します。しかし、私はhdfs_pathを実行するとき:
File "test_hdfs.py", line 73, in <module>
save_path = saver.save(sess, hdfs_path+"save_net.ckpt")
File "/data/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1354, in save
"Parent directory of {} doesn't exist, can't save.".format(save_path))
これはtf.summary.FileWriter関数を使用すると同様に発生します。 hdfs_pathを使用すると、プログラムが固執する。私はlocal_pathを使用すると、okを実行します。
私の全体のコードは次のようである:
hdfs_path="hdfs://*"
local_path = "./"
with tf.Session(graph=tf.get_default_graph()) as sess:
W = tf.Variable([[1,2,3],[3,4,5]], dtype=tf.float32, name='weights')
b = tf.Variable([[1,2,3]], dtype=tf.float32, name='biases')
init = tf.group(tf.global_variables_initializer(),tf.local_variables_initializer())
saver = tf.train.Saver()
sess.run(init)
summary_writer = tf.summary.FileWriter(hdfs_path,graph_def=sess.graph_def)
saver.save(sess,save_path=hdfs_path+"save_net.ckpt")
私は自分の環境をテストしており、Popenを使ってpythonコードでhdfsにファイルを書き込むことができます。 https://github.com/tensorflow/tensorflow/issues/5112の他の質問は、テンソルフロー0.11を使用したときにこの問題に取り組んできました。したがって、私はtensorflow 1.0がwrite hdfsを直接サポートできると思います。 –
コメントを投稿するのではなく、あなたの質問にその情報を編集することができます。 – WhatsThePoint
コードに変更を加えて質問に編集すると、正しくフォーマットできます – WhatsThePoint