Reputation: 20886
Im trying to initialize a FIFOQueue similar to the shape of my numpy array but get the below error.
My - numpy array shape - (1, 17428, 3)
dtypes=[tf.float32,tf.float32,tf.float32]
print len(dtypes)
shapes=[1, 17428, 3]
print len(shapes)
q = tf.FIFOQueue(capacity=200,dtypes=dtypes,shapes=shapes)
ValueError: Queue shapes must have the same length as dtypes
Upvotes: 2
Views: 353
Reputation: 5177
The documentation specifies that the parameters for FIFOQueue
's constructor are (emphasis mine):
dtypes
: A list ofDType
objects. The length ofdtypes
must equal the number of tensors in each queue element.shapes
: (Optional.) A list of fully-definedTensorShape
objects with the same length asdtypes
, orNone
.
What you are specifying as shapes
is not a list of fully-defined TensorShape
objects, though. It is a list of three dimensions that will be interpreted as one TensorShape
resulting in shapes=[TensorShape([Dimension(1), Dimension(17428), Dimension(3)])]
which is of length 1. To tell the constructor that you want three 1D tensors you can specify:
shapes=[tf.TensorShape(1), tf.TensorShape(17428), tf.TensorShape(3)]
Then q = tf.FIFOQueue(capacity=200,dtypes=dtypes,shapes=shapes)
will run and no error will be raised.
Upvotes: 3