AttributeError: 模块“tensorflow.python.summary.summary”没有属性“FileWriter”

McL*_*odx 6 python tensorflow tensorboard

我收到了这个错误,尽管我看过的所有地方file_writer = tf.summary.FileWriter('/path/to/logs', sess.graph)都提到了thisthis的正确实现。

这是错误:

回溯(最近一次调用):文件“tfvgg.py”,第 304 行,在 writer = tf.summary.FileWriter(“/tmp/tfvgg”, sess.graph) AttributeError: module 'tensorflow.python.summary.summary'没有属性“FileWriter”

这是我正在使用的代码:

# init
sess = tf.Session()
writer = tf.summary.FileWriter("/tmp/tfvgg", sess.graph)
init = tf.initialize_all_variables()
sess.run(init)
Run Code Online (Sandbox Code Playgroud)

FileWriter与其他summary方法一样,正确的使用方法是否发生了变化?

McL*_*odx 5

为了供任何处于相同情况的人将来参考,进行更改tf.summary.FileWriter()tf.train.SummaryWriter()解决此问题并允许在 Tensorboard 中进行图形可视化。正如我所想,它似乎可能已被弃用(尽管在 IDE 中FileWriter搜索方法时它仍然奇怪地出现)tf