TensorFlow基础4——tf.placeholder()

tf.placeholder()输入变量

函数中使用tf.placeholder()时,在调用该函数(sess.run())要加入参数(feed_dict)

1 import tensorflow as tf 
2 
3 input1 = tf.placeholder(tf.float32)
4 input2 = tf.placeholder(tf.float32)
5 
6 output = tf.multiply(input1,input2)
7 
8 with tf.Session() as sess:
9     print(sess.run(output,feed_dict={input1:[7.],input2:[2.0]}))

 

posted @ 2017-08-11 10:09  超任  阅读(306)  评论(0编辑  收藏  举报