出队时出现问题(Tensorflow,python3.4)

时间:2018-11-26 13:58:03

标签: python-3.x tensorflow queue

我出队时遇到了问题。这是我的代码:

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

filenames_image, label_image = input_queue.dequeue()
pfi = tf.Print(filenames_image, data=[input_queue.size(), filenames_image], message='This is how many items are left in q1: ')
filenames_sound, label_sound = input_queue.dequeue()
pfs = tf.Print(filenames_sound, data=[input_queue.size(), filenames_sound], message='This is how many items are left in q2: ')

在会话中,“ image”和“ son”是路径(字符串)的列表:

while h < 50 :
    sess.run(enqueue_op, {image_paths_placeholder: image, labels_placeholder: labelI})
    sess.run(enqueue_op, {image_paths_placeholder: son, labels_placeholder: labelS}
    filename_i,filename_s,_,_,=sess.run([filenames_image,filenames_sound,pfi,pfs],feed_dict=feed_dict)

有时,我不知道为什么,如何或何时出队无法满足我的要求。

我想要

This is how many items are left in q2: [1][I1,I2,I3]
This is how many items are left in q1: [0][S1,S2,S3]

但是我经常得到其他东西,

This is how many items are left in q2: [2][S1,S2,S3]
This is how many items are left in q1: [2][I1,I2,I3]

甚至

This is how many items are left in q2: [2][I1,I2,I3]
This is how many items are left in q1: [0][S1,S2,S3]

This is how many items are left in q2: [1][S1,S2,S3]
This is how many items are left in q1: [1][I1,I2,I3]

如果有人可以解释队列的工作方式以及为什么我的代码不起作用,那真是太棒了!

谢谢。

0 个答案:

没有答案