原型:spa
placeholder 是 Tensorflow 中的佔位符,若是想要從外部傳入data, 那就須要用到 tf.placeholder(),而後以這種形式傳輸數據 sess.run(***, feed_dict={input: **})傳入數據。code
placeholder 與 feed_dict={} 是綁定在一塊兒出現的;這裏沒有變量,就不須要在上兩個筆記的 init =tf.global_variables_initializer() 這一步了。blog
具體練習的代碼:ip
import tensorflow as tf a1 = tf.placeholder(tf.float32) a2 = tf.placeholder(tf.float32) output = tf.multiply(a1,a2) with tf.Session() as sess: print(sess.run(output,feed_dict={a1:[3.],a2:[8.]}))
結果:[24.]input