Created
November 18, 2016 15:31
-
-
Save reuben/3122ee11b7077e10318538ee01d79d7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tensorflow as tf | |
| q1 = tf.FIFOQueue(capacity=100, dtypes=[tf.int32], shapes=[[]]) | |
| q2 = tf.FIFOQueue(capacity=100, dtypes=[tf.int32], shapes=[[]]) | |
| q3 = tf.FIFOQueue(capacity=100, dtypes=[tf.int32], shapes=[[]]) | |
| idx = tf.placeholder(tf.int32) | |
| def deq1(): | |
| return tf.Print(q1.dequeue(), [1], "deq1 called") | |
| def deq2(): | |
| return tf.Print(q2.dequeue(), [2], "deq2 called") | |
| def deq3(): | |
| return tf.Print(q3.dequeue(), [3], "deq3 called") | |
| batch = tf.cond(tf.equal(idx[0], 1), deq1, lambda: tf.cond(tf.equal(idx[0], 2), deq2, deq3)) | |
| s = tf.InteractiveSession() | |
| s.run(tf.initialize_all_variables()) | |
| tf.train.start_queue_runners(sess=s) | |
| for i in range(10): | |
| s.run(q1.enqueue(10+i)) | |
| s.run(q2.enqueue(20+i)) | |
| s.run(q3.enqueue(30+i)) | |
| print(s.run(batch, feed_dict={idx: [1]})) | |
| print(s.run(batch, feed_dict={idx: [2]})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment