原代码:
with tf.compat.v1.Session() as sess: print(sess.graph) filewriter = tf.compat.v1.summary.FileWriter("./tmp/summary/", graph=sess.graph) c_sum = sess.run(c) print(c_sum)
原因是with tf.compat.v1.Session() as sess:这行代码不能与下面的代码对齐
解决方案:
with tf.compat.v1.Session() as sess: print(sess.graph) filewriter = tf.compat.v1.summary.FileWriter("./tmp/summary/", graph=sess.graph) c_sum = sess.run(c) print(c_sum)
将with tf.compat.v1.Session() as sess: 后面的代码全部缩进一下就可以了