tensorflow输出
在Session对象上调用run()函数,执行流图,即可得到输出,
可获取单个输出,也可获取多个输出
import tensorflow as tf import numpy as np constant_A = tf.constant([100.0]) constant_B = tf.constant([300.0]) constant_C = tf.constant([3.0]) sum_ = tf.add(constant_A, constant_B) mul_ = tf.multiply(constant_A, constant_C) with tf.Session() as sess: # print (sess.run(tensor_id.get_shape())) result_sum = sess.run(sum_) # 单个输出 print ("constant_A + constant_B = ", result_sum) print ("*******************") # 两个输出 result_sum, result_mul = sess.run([sum_, mul_]) print ("constant_A + constant_B = ", result_sum) print ("constant_A * constant_C = ", result_mul)