tf.placeholder函数

官方文档:

input1 = tf.placeholder(tf.types.float32)
input2 = tf.placeholder(tf.types.float32)
output = tf.mul(input1, input2)

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

# 输出:
# [array([ 14.], dtype=float32)]

运行之后发现错误:AttributeError: 'module' object has no attribute 'types'

用的是TensorFlow1.7.0,参考了一下:placeholder函数

改成

input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)

就可以了

猜你喜欢

转载自blog.csdn.net/cong427/article/details/80242328