How to enqueue data from a python function into a TensorFlow queue -


i have python function automatically generates a (data,label) pair when call it. don't know how attach function tensorflow fifoqueue, queue filled data generated function. code have far is:

myq = tf.fifoqueue(5000, [tf.float32, tf.float32], [[4],[1]]) enqueue_op = myq.enqueue(read_data()) # read_data() returns 2 numpy arrays of shape [4] , [1] qr = tf.train.queuerunner(myq, [enqueue_op]*2) ... threads = qr.create_threads(sess=sess,coord=coord, start=true) 

however, calls function read_data() once , keeps pushing same value queue. how correctly hook function enqueue method, can populate queue data function (preferably using multiple threads in background). help.

i understand read_data own code, not tf operations. need placeholder enqueue_op, feed data using feed_dict.

# graph setup x_enqueue = tf.placeholder(tf.float32, shape=(4)) y_enqueue = tf.placeholder(tf.float32, shape=(1)) enqueue_op = myq.enqueue([x_enqueue, y_enqueue])  ...  # enqueue loop: x_read, y_read = read_data() sess.run(enqueue_op, feed_dict={x_enqueue: x_read, y_enqueue: y_read}) 

Comments