tensorflow - How to understand constructor of tf.FIFOQueue? -
i have written code, can't explain well.
the first code:
import tensorflow tf f = tf.fifoqueue(10, [tf.int32, tf.int32]) en = f.enqueue([[1,2],[3,4]]) de = f.dequeue() tf.session() sess: en.run() x = sess.run(de) print(x)
i define element of queue tuple of tensor, when enqueue [[1,2],[3,4]]
, works , output [array([1, 2]), array([3, 4])]
.
but second code, can't understand.
import tensorflow tf f = tf.fifoqueue(10, [tf.int32]) en = f.enqueue([1,2,3,4]) de = f.dequeue() tf.session() sess: en.run() x = sess.run(de) print(x)
according first code, think output [array(1, 2, 3, 4)]
, in fact, output 1
. how explain second code?
if change arguments in enqueue operation of second code to:
en = f.enqueue([[1,2,3,4]])
you have results supposed.
you can use shape
argument in constructor of tf.fifoqueue
more definiteness. example if change code as:
import tensorflow tf f = tf.fifoqueue(10, [tf.int32], shapes = [4]) en = f.enqueue([1,2,3,4]) de = f.dequeue() tf.session() sess: en.run() x = sess.run(de) print(x)
you receive error on f.enqueue
operation.
but if use this:
import tensorflow tf f = tf.fifoqueue(10, [tf.int32], shapes = [4]) en = f.enqueue([[1,2,3,4]]) de = f.dequeue() tf.session() sess: en.run() x = sess.run(de) print(x)
you have no errors.
Comments
Post a Comment