【问题标题】:Tensorflow failed to create a newwriteablefile when retraining inceptionTensorflow 在重新训练初始时无法创建新的可写文件
【发布时间】:2017-12-18 00:24:14
【问题描述】:

我正在关注本教程:https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/?utm_campaign=chrome_series_machinelearning_063016&utm_source=gdev&utm_medium=yt-desc#4

我正在运行这部分代码:

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

这是我在找到图像后遇到的错误,造成了一堆瓶颈并且还进行了步骤训练。

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.

你可以在这里找到我的所有代码: https://github.com/officialgupta/MachineLearningRecipes

谢谢

【问题讨论】:

    标签: python windows machine-learning tensorflow python-3.5


    【解决方案1】:

    我有同样的问题。我唯一要做的就是减少路径的长度。

    例如:

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

    而不是

    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.

    【讨论】:

    • 如何减少路径名?
    • 正如您在我的示例中看到的,我为保存的模型使用了一个较短的名称:neural20201029-235456-a0.8775 而不是neural20201029-234822Arg-e1-b512-l1-n256-oadam-z0.005-r0-d0-a0.8803
    • 嗨,我可以看到你已经改变了它,但我有兴趣怎么做?在链接中是我原来的问题,你会如何在这里改变位置? stackoverflow.com/questions/65974699/…
    • 我在 Keras 中使用model.save(path) 方法。因此,我必须传递一个路径参数,我可以按照上述方式进行修改。
    • 您选择路径名称的方式背后是否有任何逻辑
    【解决方案2】:

    我遇到了同样的问题,并且可以解决它。

    只是为了澄清一些事情,我的代码在没有 .. 的情况下运行。

    • 设置绝对路径
    • 激活张量流

    在第一次运行时,一切都按预期保存,在第二次运行时,我遇到了与描述相同的问题。

    对我来说,不设置就足够了

    --save_model_dir
    

    但只是设置

    --output_labels
    --output_graph
    

    【讨论】:

      【解决方案3】:

      在win10下试试下面的命令解决问题

      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
      

      【讨论】:

      • 你能解释一下为什么这是一个解决方案吗?此外,您可以在代码周围使用 ` ` 使其看起来像 code
      【解决方案4】:

      在类似的情况下,我在尝试执行此命令时遇到了错误:

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

      然后我发现,output_path 是空的。所以你需要确保绝对路径可用。

      【讨论】:

      • 不适用于 tf 2.6.0
      【解决方案5】:

      我可能迟到了,但我给出了一个答案,希望它对遇到类似问题的人有用。

      今天我在 Tensorflow 上重新训练 Inception 模型时遇到了类似的问题,并按照一些步骤进行了纠正。

      我们需要注意两件事。

      1. 在使用 Tensorflow 命令之前激活 tensorflow。

        来源 ~/tensorflow/bin/activate

      2. 使用@Nikita Verbitskiy 在下面的答案中回答的终端命令中提到的文件的完整路径。

      【讨论】:

        【解决方案6】:

        我也发现了一些类似的错误。如果我理解,您需要为--output_graph--output_labels 设置绝对路径。

        例如:

        --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 
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-10-23
          • 1970-01-01
          • 1970-01-01
          • 2018-03-19
          • 1970-01-01
          相关资源
          最近更新 更多