1. 程式人生 > >tensorflow中的placeholder的機制

tensorflow中的placeholder的機制

import tensorflow as tf

input1=tf.placeholder(tf.float32)
input2=tf.placeholder(tf.float32)
output=tf.multiply(input1,input2)

with tf.Session() as sess:
	print(sess.run(output,feed_dict={input1:[7.],input2:[2.]}))

在tensorflow中,有一個機制叫做placeholder,首先建立變數但是不進行賦值,在最後sess.run(op,feed_dict={  }  )用feed_dict進行賦值操作,