import tensorflow as tf
# ===========Fetch============
input1 = tf.constant(3.0)
input2 = tf.constant(2.0)
input3 = tf.constant(5.0)
add = tf.add(input2, input3)
mul = tf.multiply(input1, add)
sub = tf.subtract(input3, input1)
with tf.Session() as sess:
# 所谓的Fetch就是同时运行多个op
result = sess.run([add, mul, sub])
print(result)
# ===========Feed============
input4 = tf.placeholder(tf.float32)
input5 = tf.placeholder(tf.float32)
mul2 = tf.multiply(input4, input5)
with tf.Session() as sess:
# 所谓的Feed就是在执行的时候才以字典的形式传入值
result = sess.run(mul2, feed_dict={input4:[7.0],input5:[2.0]})
print(result)
结束线/
欢迎大家加入Q群讨论:463255841
结束线/