基于Monster 组和GPT的调写:
指定要使用的图形并获得 a+b 的正确输出:
import tensorflow as tf
# 创建新图形
graph = tf.Graph()
# 将图形设置为默认图形
with graph.as_default():
a = tf.constant([1,3])
b = tf.constant([2,4])
c = tf.add(a, b)
# 创建会话并使用新图形
with tf.compat.v1.Session(graph=graph) as sess:
print(sess.run(c))