飞翔鸟

人生无止境,奋斗不息

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)
tensorflow的输出

 

 

 

posted @ 2018-07-10 15:24  飞翔—鸟  阅读(416)  评论(0编辑  收藏  举报