当我从控制台运行python代码时,一切正常:我每次都会得到一个新的tensorboard文件(626字节),我可以使用tensorboard服务查找它。在
但是,当我从Spyder IDE运行此代码时,每次运行后都会有一个新文件,其中包含自Spyder启动以来所有运行的数据。在Spyder中运行了10次之后,即使我关闭了tensorboard服务器并用日志删除了dir,在第11次运行之后,会有一个大约6K大小的新文件,包含所有以前的运行。在
import tensorflow as tf
a = tf.constant(2,name ='a')
b = tf.constant(3,name = 'b')
x = tf.add(a, b)
with tf.Session() as sess:
# add this line to use TensorBoard.
writer = tf.summary.FileWriter('./graphs', sess.graph)
print (sess.run(x))
writer.close() # close the writer when you’re done using i
在Spyder restart之后,整个故事又开始了,第一次运行产生了正确的结果,而第二次运行已经包含了之前的数据。在
Spyder IDE做一些缓存或者什么?在
好吧,我找到了我自己问题的答案。Spyder:Tools—>;Preferences—>;Run—>;“Clear all variables before execution”中有一个设置
(也在“运行”>;“每个文件的配置”中。。。->;'执行前清除所有变量')
详细信息:https://github.com/spyder-ide/spyder/issues/2563
相关问题 更多 >
编程相关推荐