Tensorflow failed to create a newwriteablefile when retraining inception

故事扮演 提交于 2021-02-08 12:59:13

问题


I am following this tutorial: https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/?utm_campaign=chrome_series_machinelearning_063016&utm_source=gdev&utm_medium=yt-desc#4

I am running this part of the code:

python retrain.py \
  --bottleneck_dir=bottlenecks \
  --how_many_training_steps=500 \
  --model_dir=inception \
  --summaries_dir=training_summaries/basic \
  --output_graph=retrained_graph.pb \
  --output_labels=retrained_labels.txt \
  --image_dir=flower_photos

Here is the error that I get after it finds the images, makes a bunch of bottlenecks and also does steps training.

Traceback (most recent call last):
  File "retrain.py", line 1062, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "retrain.py", line 905, in main
    f.write('\n'.join(image_lists.keys()) + '\n')
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 101, in write
    self._prewrite_check()
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 87, in _prewrite_check
    compat.as_bytes(self.__name), compat.as_bytes(self.__mode), status)
  File "C:\Anaconda3\lib\contextlib.py", line 66, in __exit__
    next(self.gen)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a NewWriteableFile: /tmp/output_labels.txt : The system cannot find the path specified.

You can find all my code here: https://github.com/officialgupta/MachineLearningRecipes

Thanks


回答1:


I have also found some similar errors. And if I understood, that you need to set an absolute paths for --output_graph and --output_labels.

For example:

--output_graph=/home/%your_homhttps://stackoverflow.com/review/late-answers/17020426#e_user_name_folder%/Inception_retrained_graph.pb 
--output_labels=/home/%your_home_user_name_folder%/Inception_retrained_labels.txt 



回答2:


In a similar case,I have met errors, when I tried to execute this command:

writer = tf.python_io.TFRecordWriter(FLAGS.output_path)

then I found that, the output_path is empty. So you need to make sure an absolute paths is available.




回答3:


I might be late for giving an answer but putting up an answer and hoping that it will be useful for anyone facing similar issue.

Today I came across similar issue while retraining the Inception model on Tensorflow and followed some steps to correct it.

There are two things we need to take care of.

  1. Activate tensorflow before using Tensorflow commands.

    source ~/tensorflow/bin/activate

  2. Use full path of the files mentioned in your terminal commands as answered by @Nikita Verbitskiy in the answer below.




回答4:


try below command in win10 to solve the problem

python -m retrain 
--bottleneck_dir=bottlenecks
--how_many_training_steps=500 
--model_dir=models 
--summaries_dir=tf_files 
--output_graph=retrained.pb 
--output_labels=retrained_labels.txt 
--architecture="mobilenet_0.50_224" 
--image_dir=flower_photos



回答5:


I faced the same problem, and could fix it.

Just to clear some things up, my code is running without ..

  • setting an absolute path
  • activating tensorflow

On the first run everything was saved as expected, on the second run I had the same issue as described.

For me it was enough to not set

--save_model_dir

but only setting

--output_labels
--output_graph



回答6:


I had the same issue. The only thing I had to do is to reduce the length of path.

For example:

C:\Users\test\lib\Workspace\DataScience\Bachelorarbeit\ba_test\src\saved_models\neural20201029-235456-a0.8775

instead of

C:\Users\test\lib\Workspace\DataScience\Bachelorarbeit\ba_test\src\saved_models\neural20201029-234822Arg-e1-b512-l1-n256-oadam-z0.005-r0-d0-a0.8803.



来源:https://stackoverflow.com/questions/45076911/tensorflow-failed-to-create-a-newwriteablefile-when-retraining-inception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!