问题描述
我收到此错误,尽管我到处查看 file_writer = tf.summary.FileWriter('/path/to/logs', sess.graph)
被认为是正确的实现this 和 this.
I'm getting this error, although everywhere I've looked file_writer = tf.summary.FileWriter('/path/to/logs', sess.graph)
is mentioned as the correct implementation of this and this.
这里是错误:
回溯(最近一次调用最后一次):文件tfvgg.py",第 304 行,在writer = tf.summary.FileWriter("/tmp/tfvgg", sess.graph) AttributeError: 模块 'tensorflow.python.summary.summary' 没有属性 'FileWriter'
这是我正在使用的代码:
Here is the code I'm using:
# init
sess = tf.Session()
writer = tf.summary.FileWriter("/tmp/tfvgg", sess.graph)
init = tf.initialize_all_variables()
sess.run(init)
使用 FileWriter
的正确方法是否与其他 summary
方法一样有变化?
Has there been a change to the correct way to use FileWriter
as there has been with other summary
methods?
推荐答案
为了将来遇到相同情况的任何人的参考,将 tf.summary.FileWriter()
更改为 tf.train.SummaryWriter()
解决了这个问题,并允许在 Tensorboard 中进行图形可视化.正如我所想,似乎 FileWriter
可能已被弃用(尽管在 IDE 中搜索 tf
方法时它仍然奇怪地出现)
For future reference of anyone in the same situation, changing tf.summary.FileWriter()
to tf.train.SummaryWriter()
solved this issue and allowed for graph visualisation in Tensorboard. As I thought, it seems like FileWriter
may be deprecated (although it does oddly still appear when searching through tf
methods in the IDE)
这篇关于AttributeError: 模块“tensorflow.python.summary.summary"没有属性“FileWriter"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!