1.图基础(Graph basics)
节点(Nodes):图中”add”
边(Edges):对应三条线
2.TensorFlow中的计算图(Computation Graphs in TensorFlow)
所有TensorFlow工程由如下两个部分组成:
1)定义计算图(Define the computation graph)
2)运行图(Run the graph(with data))
3.建立第一个TensorFlow图(Building the frist TensorFlow graph)
代码:
# coding: utf-8
#
import tensorflow as tf
# Define the computation graph
a = tf.constant(5,name = "input_a")
b = tf.constant(3,name = "input_b")
c = tf.multiply(a,b,name = "mul")
d = tf.add(a,b,name = "add")
e = tf.add(c,d,name = "add")
# Run the graph(with data
sess = tf.Session()
sess.run(e)
sess.run(c)
# Graph
writer = tf.summary.FileWriter('./my_graph',sess.graph)
writer.close()
sess.close()
显示图:
1)输入命令:
$tensorboard --logdir="test"
或
$tensorboard --logdir=./test
2)输入网址:
说明:加码部分为本地主机名(localhost)
3)最终显示:
参考资料
[1] TENSORFLOW FOR MACHINE INTELLIGENCE.pdf Chapter3. TensorFlow Fundamentals