- , , tf.where, , , tf.gather, . , , - - tf.train.batch:
:
import numpy as np
import tensorflow as tf
a = tf.constant(np.array([5, 1, 9, 4, 7, 0], dtype=np.int32))
q = tf.FIFOQueue(6, dtypes=[tf.int32], shapes=[])
enqueue = q.enqueue_many([a])
dequeue = q.dequeue_many(6)
predmatch = tf.less(dequeue, [5])
selected_items = tf.reshape(tf.where(predmatch), [-1])
found = tf.gather(dequeue, selected_items)
secondqueue = tf.FIFOQueue(6, dtypes=[tf.int32], shapes=[])
enqueue2 = secondqueue.enqueue_many([found])
dequeue2 = secondqueue.dequeue_many(3)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(enqueue)
sess.run(enqueue2)
print sess.run(dequeue2)
; tf.where , tf.gather .
, , , - , , , , ( ). , QueueRunners , . tf.train.batch - . Threading and Queues.