tensorflow 學習紀錄(持續更新)
阿新 • • 發佈:2018-06-16
使用 一個 ant lidar value nod traceback err erro
1 import tensorflow as tf 2 import numpy as np 3 4 #tensor = tf.constant([[1,2,3,4,5,6,7,8],[1,2,3,4,5,6,7,8]]) 5 tensor = tf.placeholder(tf.int32, [2,8]) 6 7 with tf.Session() as sess: 8 sess.run(tf.global_variables_initializer()) 9 print sess.run(tensor,feed_dict={tensor:[[1,2,3,4,5,6,7,8],[1,2,3,4,5,6,7,8]]})10 print sess.run(tensor) 11 tensorReshape = tf.reshape(tensor,[-1,4]) 12 print sess.run(tensorReshape)
print sess.run(tensor) 會報錯,
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor ‘Placeholder‘ with dtype int32 and shape [2,8]
[[Node: Placeholder = Placeholder[dtype=DT_INT32, shape=[2,8], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
原因:feed 使用一個 tensor 值臨時替換一個操作的輸出結果. 你可以提供 feed 數據作為 run()
調用的參數. feed 只在調用它的方法內有效, 方法結束, feed 就會消失。
tensorflow 學習紀錄(持續更新)