我正在遵循TensorFlow Mechanics 101(版本0.7.0)的教程。根据文档,我下载了两个文件(mnist.py
和fully_connected_feed.py
)并将它们保存到本地计算机上的同一目录中。
当我运行以下命令时:
$ python /FULL_PATH_TO_fully_connected_feed.py/fully_connected_feed.py
...我收到此错误:OSError: [Errno 2] No such file or directory: ''
。完整输出和堆栈跟踪如下:
...
...
Step 800: loss = 0.56 (0.005 sec)
Step 900: loss = 0.51 (0.004 sec)
Traceback (most recent call last):
File "./fully_connected_feed.py", line 228, in <module>
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/default/_app.py", line 30, in run
sys.exit(main(sys.argv))
File "./fully_connected_feed.py", line 224, in main
run_training()
File "./fully_connected_feed.py", line 199, in run_training
saver.save(sess, FLAGS.train_dir, global_step=step)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 970, in save
self.export_meta_graph(meta_graph_file_name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 990, in export_meta_graph
as_text=as_text)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1315, in export_meta_graph
os.path.basename(filename), as_text=as_text)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/training_util.py", line 70, in write_graph
gfile.MakeDirs(logdir)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/default/_gfile.py", line 295, in MakeDirs
os.makedirs(path, mode)
File "/usr/lib/python2.7/os.py", line 160, in makedirs
mkdir(name, mode)
OSError: [Errno 2] No such file or directory: ''
答案 0 :(得分:1)
这是TensorFlow的0.7.0版本中的一个错误,该错误已在a recent commit中修复,并将很快出现在错误修正版本中。当--train_dir
标志不包含目录名称组件时,会导致该问题。
与此同时,您可以在运行示例时传递标记--train_dir=./
来避免此问题。
答案 1 :(得分:0)
这应该是对mrry帖子的评论(我缺少声望)
将第42行从fully_connected_feed.py更改为
flags.DEFINE_string('train_dir', './data', 'Directory to put the training data.')
为我解决了这个问题。我也是0.7.0并且能够运行所有其他mnist示例。