【问题标题】:Tensorflow: Label inception has no images in the category trainingTensorflow:标签初始在类别训练中没有图像
【发布时间】:2017-05-23 09:36:48
【问题描述】:

我正在根据此处的代码重新训练 Inception v3 网络:https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#0。 我有一组 200 个标签。每个标签的图像数量从 50 到 15000 不等。重新训练时出现以下错误:

2017-01-08 07:42:09.683263: Step 30: Train accuracy = 6.0%
2017-01-08 07:42:09.683384: Step 30: Cross entropy = 6.297137
2017-01-08 07:42:09.808175: Step 30: Validation accuracy = 0.0%
2017-01-08 07:42:11.083850: Step 40: Train accuracy = 2.0%
2017-01-08 07:42:11.083964: Step 40: Cross entropy = 6.296147
CRITICAL:tensorflow:Label corset has no images in the category validation.
Traceback (most recent call last):
 File "tensorflow/examples/image_retraining/retrain.py", line 1012, in <module>
   tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
 File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 43, in run
   sys.exit(main(sys.argv[:1] + flags_passthrough))
 File "tensorflow/examples/image_retraining/retrain.py", line 839, in main
   bottleneck_tensor))
 File "tensorflow/examples/image_retraining/retrain.py", line 480, in get_random_cached_bottlenecks
   bottleneck_tensor)
 File "tensorflow/examples/image_retraining/retrain.py", line 388, in get_or_create_bottleneck
   bottleneck_dir, category)
 File "tensorflow/examples/image_retraining/retrain.py", line 245, in get_bottleneck_path
   category) + '.txt'
 File "tensorflow/examples/image_retraining/retrain.py", line 221, in get_image_path
   mod_index = index % len(category_list)
ZeroDivisionError: integer division or modulo by zero`

在 google 上搜索让我明白,如果图像少于 20 个,则可能会发生此类错误。这可能是因为它们可能没有足够的图像进行验证。但是我至少有 50 张图片。那么为什么我会收到这个错误呢?

【问题讨论】:

    标签: image-processing machine-learning tensorflow neural-network conv-neural-network


    【解决方案1】:

    我查看了您帖子中教程链接的tensorflow/examples/image_retraining/retrain.py 文件。

    运行的部分代码是在函数 create_image_lists(image_dir, testing_percentage, validation_percentage) 中进行的训练/验证拆分

    拆分的默认值为 10%,并在 FLAGS.validation_percentage 中说明

    由于您有少于 200 张图像的类,因此拆分返回少于 20 张照片的类进行验证,这就是您遇到错误的地方。

    尝试仅使用包含 200 多个图像的类运行代码,看看是否有帮助。如果是,您可以考虑添加更多图像或操作 create_image_lists 函数以返回至少 20 张照片进行验证。

    【讨论】:

    • 是的,它奏效了。我将更多图像添加到图像少于 200 个的类中,并使最终计数超过 200 个。
    猜你喜欢
    • 1970-01-01
    • 2020-11-17
    • 2017-12-16
    • 1970-01-01
    • 2017-04-06
    • 2019-02-02
    • 2017-07-01
    • 2017-05-15
    • 2017-01-13
    相关资源
    最近更新 更多