FIFOQueue已关闭且元素不足

时间:2018-02-17 04:06:39

标签: tensorflow queue

我尝试使用自己的数据集(脚本train_tripletloss.py)运行FaceNet tensorflow's implementation of David Sandberg。在某些时候训练执行因为:

而停止
tensorflow.python.framework.errors_impl.OutOfRangeError, FIFOQueue '_0_batch_join/fifo_queue' is closed and has insufficient elements (requested 9, current size 0) 

异常似乎是由batch_join操作引起的。我在某个地方读过它可能是空队列造成的。因为我是Tensorflow的初学者,所以我不知道在哪里查看以及如何调试。以下是代码的一部分:

    input_queue = data_flow_ops.FIFOQueue(capacity=100000,
                                dtypes=[tf.string, tf.int64],
                                shapes=[(3,), (3,)],
                                shared_name=None, name=None,)
    enqueue_op = input_queue.enqueue_many([image_paths_placeholder, labels_placeholder])

    nrof_preprocess_threads = 4
    images_and_labels = []
    for _ in range(nrof_preprocess_threads):
        filenames, label = input_queue.dequeue()
        images = []
        for filename in tf.unstack(filenames):
            file_contents = tf.read_file(filename)
            image = tf.image.decode_image(file_contents, channels=3)

            ...
            image.set_shape((args.image_size, args.image_size, 3))
            images.append(tf.image.per_image_standardization(image))
        images_and_labels.append([images, label])


    image_batch, labels_batch = tf.train.batch_join(
        images_and_labels, batch_size=batch_size_placeholder, 
        shapes=[(args.image_size, args.image_size, 3), ()], 
        enqueue_many=True,
        capacity=4 * nrof_preprocess_threads * args.batch_size,
        allow_smaller_final_batch=True)
    image_batch = tf.identity(image_batch, 'image_batch')
    image_batch = tf.identity(image_batch, 'input')
    labels_batch = tf.identity(labels_batch, 'label_batch')

任何人都可以提供帮助吗?

1 个答案:

答案 0 :(得分:0)

失败的原因是MacOS已将此死的隐藏文件(.DS_Store)添加到我的图像目录中。