3.4 TensorFlow计算模型 – 数据流图
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
# 一个简单计算图
node1 = tf.constant(3.0,tf.float32,name="node1")
node2 = tf.constant(4.0,tf.float32,name="node2")
node3 = tf.add(node1, node2)
print(node3)
# 建立对话并显示运行结果
sess = tf.Session()
print("运行sess.run(node1)的结果:", sess.run(node1))
# 更新变量并返回计算结果
print("运行sess.run(node3)的结果:", sess.run(node3))
# 关闭session
sess.close()