placeholder

来源:互联网 发布:网络打卡 编辑:程序博客网 时间:2024/05/17 22:42

placeholder作用就是接受外部传来的数据,相当于一个占位符。
变量值不再是直接在图中tensorflow图中定义,而是给出一个占位符,在session中再给值。
palceholder

# View more python learning tutorial on my Youtube and Youku channel!!!# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg# Youku video tutorial: http://i.youku.com/pythontutorial"""Please note, this code is only for python 3+. If you are using python 2+, please modify the code accordingly."""from __future__ import print_functionimport tensorflow as tfinput1 = tf.placeholder(tf.float32)input2 = tf.placeholder(tf.float32)ouput = tf.multiply(input1, input2)with tf.Session() as sess:    print(sess.run(ouput, feed_dict={input1: [7.], input2: [2.]}))
0 0