目录
[1.1 init(target='',graph=None,config=None)](#1.1 init(target='',graph=None,config=None))
[1.2 会话的run()](#1.2 会话的run())
[1.3 feed操作](#1.3 feed操作)
- TF数据流图
- 图与TensorBoard
- 会话
- 张量
- 变量OP
- 高级API
1、会话

1.1 init(target='',graph=None,config=None)


python
def session_demo():
# 会话的演示
# Tensorflow实现加法运算
a_t = tf.constant(2)
b_t = tf.constant(3)
c_t = a_t + b_t
print("tensorflow:\n", c_t)
# 查看默认图
# 方法1:调用方法
default_g = tf.get_default_graph()
# default_g =tf.compat.v1.get_default_graph
print("default:\n", default_g)
# 方法2:查看属性
print("a_t的图属性:\n", a_t.graph)
print("c_t的图属性:\n", c_t.graph)
# 开启会话
with tf.Session(config=tf.ConfigProto(allow_soft_placement=True,
log_device_placcement=True)) as sess:
c_t_value = sess.run(c_t)
print("c_t_value:\n", c_t_value)
print("sess的图属性:\n", sess.graph)
# 将图写入本地生成events文件
tf.summary.FileWriter("./tmp/summary",graph=sess.graph)
return None
1.2 会话的run()

python
# 同时查看a_t,b_t,c_t
abc = sess.run([a_t,b_t,c_t])
1.3 feed操作




