0

在 Ubuntu 15.10 64bit 和 python 2.7 上执行 train_mnist.py 时,出现以下错误(IOError: [Errno 2] No such file or directory: 'result/cg.dot')。让我知道如何解决它。

survey@SURVEY-C11:~/chainer/examples/mnist$ python train_mnist.py
GPU: -1
# unit: 1000
# Minibatch-size: 100
# epoch: 20

Traceback (most recent call last):
  File "train_mnist.py", line 115, in <module>
    main()
  File "train_mnist.py", line 112, in main
    trainer.run()
  File "/home/survey/anaconda2/lib/python2.7/site-packages/chainer/training/trainer.py", line 292, in run
    entry.extension(self)
  File "/home/survey/anaconda2/lib/python2.7/site-packages/chainer/training/extensions/computational_graph.py", line 57, in dump_graph
    with open(out_path, 'w') as f:
IOError: [Errno 2] No such file or directory: 'result/cg.dot'
4

1 回答 1

1

open(..., 'w')不会为您创建中间目录;确保目录result存在。

import os
# Make sure the result directory exist
if not os.path.exists('result'):
    os.path.mkdir('result')

...
于 2017-01-22T06:51:02.297 回答