因爲我是tensorflow的新手,我不知道如何定義tf.PaddingFIFOQueue的形狀來將元素設置爲N * 1數組。我認爲下面的代碼應該可以工作,但它會產生錯誤...我可以幫助我調試tf.PaddingFIFOQueue錯誤嗎?
你能給我一個提示來調試嗎?
import tensorflow as tf
import numpy as np
a = tf.placeholder(dtype= tf.float32, shape = [None, 1])
b = tf.placeholder(dtype= tf.float32, shape = [None, 1])
ab_value = np.random.randn(5,1)
m = ab_value.reshape(-1, 1)
q_ab = tf.PaddingFIFOQueue(32, ['float32', 'float32'], shapes = [[None, 1], [None, 1]])
q_ab_en = q_ab.enqueue_many([a, b])
sess = tf.Session()
sess.run(q_ab_en, feed_dict = {a: ab_value, b: ab_value})
#a_dq, b_dq = q_ab.dequeue_many(1)
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\data_flow_ops.py", line 375, in enqueue_many val.get_shape()[1:].assert_is_compatible_with(shape)
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 756, in assert_is_compatible_with raise ValueError("Shapes %s and %s are incompatible" % (self, other)) ValueError: Shapes (1,) and (?,1) are incompatible
謝謝你的回答!對我很有幫助!我只是通過使用enqueue而不是enqueue_many來解決問題。 – drw