tf.placehoder()占位符
tf.placeholder 函数
插入一个张量的占位符,这个张量将一直被提供.
注意:如果计算,该张量将产生一个错误,其值必须使用 feed_dict 可选参数来进行 session . run()、Tensor.eval() 或 oper.run().
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.]}))
输出为 [14.]