0

When train_mnist.py is executed on Ubuntu 15.10 64bit and python 2.7, the error(IOError: [Errno 2] No such file or directory: 'result/cg.dot') was occurred below. Let me know how to solve it.

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'
falsetru
  • 357,413
  • 63
  • 732
  • 636

1 Answers1

1

open(..., 'w') does not create the intermediate directory for you; Make sure the directory result exist.

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

...
falsetru
  • 357,413
  • 63
  • 732
  • 636