tensorflow enqueue_many傳入多個值的列表傳入異常問題————Shape () must have rank at least 1
阿新 • • 發佈:2018-11-07
tf 的佇列操作enqueue_many傳入的值是列表,但是放入[]列表拋異常
File "C:\Users\lihongjie\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\data_flow_ops.py", line 377, in enqueue_many batch_dim = vals[0].get_shape().with_rank_at_least(1)[0] File "C:\Users\lihongjie\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 765, in with_rank_at_least raise ValueError("Shape %s must have rank at least %d" % (self, rank)) ValueError: Shape () must have rank at least 1
這是由於對於tf來說接收的一切值都是tensor張量,但是這裡要想讓enqueue_many知道傳入的是列表可以設定 eqs = q.enqueue_many([[1.1,1.2,1.3],])
列表中多加一個逗號,後面不要加值,加了就不符合傳入值;這樣既是列表,又滿足tf接收的是tensor張量的需求