在学习《Tensorflow 实战Google深度学习框架》时,第9章中有个程序如下;
import tensorflow as tf
input1=tf.constant([1.0,2.0,3.0],name="input1")
input2=tf.Variable(tf.random_uniform([3]),name="input2")
output=tf.add_n([input1,input2],name="add")
writer=tf.train.SummaryWriter("/path/to/log",tf.get_default_graph())
writer.close()
跳出如下错误:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-3-999765f0fdc7> in <module>() ----> 1 writer=tf.train.SummaryWriter("/path/to/log",tf.get_default_graph()) AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter'出现问题:AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter'(0.12版本不会出现该问题)
这是因为在1.0版本中,tf.train.SummaryWriter已经改为tf.summary.FileWriter;因此,代码必须改为:
writer = tf.summary.FileWriter("C:\Users\chens\Documents\logs",tf.get_default_graph())
必须给logdir一个明确的路径定义
参考:http://blog.csdn.net/flying_sfeng/article/details/69943260