"""
图Graph
"""
import tensorflow.compat.v1 as tf
tf.compat.v1.disable_eager_execution()
x = tf.constant(100.0)
y = tf.constant(200.0)
temp = tf.add(x,y)
#获取默认图
graph = tf.get_default_graph()
print(graph)
new_graph = tf.Graph()
print("New graph", new_graph)
with new_graph.as_default():
new_op = tf.constant("Hello, Kitty")
with tf.compat.v1.Session(graph=new_graph) as sess:
print(sess.run(new_op))
with tf.compat.v1.Session(graph=graph) as sess:
print(sess.run(temp))
TensorFlow中图Graph和会话Session
最新推荐文章于 2024-10-05 20:49:35 发布