'module' 对象没有属性 'SummaryWriter' [英] 'module' object has no attribute 'SummaryWriter'
问题描述
我在 Linux CentOS 7 上使用带有 Python 2.7 的 Tensorflow 版本 0.12.head,当我运行它时:
将 tensorflow 导入为 tfa = tf.constant(5, name="input_a")b = tf.constant(3, name="input_b")c = tf.mul(a, b, name="mul_c")d = tf.add(a, b, name="add_d")e = tf.add(c, d, name="add_e")sess = tf.Session()输出 = sess.run(e)writer = tf.train.SummaryWriter('./my_graph', sess.graph)
我收到此错误:
AttributeError Traceback(最近一次调用最后一次)在 <module>()---->1 writer = tf.train.SummaryWriter('./my_graph', sess.graph)AttributeError: 'module' 对象没有属性 'SummaryWriter'
我运行了这两个命令,因为 Github 上存在相同的错误 issue问题:
<预><代码>>>>进口六>>>打印(六.__版本__)1.10.0>>>print(dir(six.moves.queue)) ['Empty', 'Full', 'LifoQueue', 'PriorityQueue', 'Queue', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_threading', '_time', 'deque', 'heapq']>>>打印(six.moves.queue.__file__)/usr/lib64/python2.7/Queue.pyc我是 Python 和 Tensorflow 的新手.你知道我该如何解决这个错误吗?
我已将 SummaryWriter
更改为 FileWriter
:
writer = tf.train.FileWriter('./my_graph', sess.graph)
我得到了同样的错误,但是使用 FileWriter
函数:
AttributeError Traceback(最近一次调用最后一次)<ipython-input-8-daa50ea2b8f9>在 <module>()---->1 writer = tf.train.FileWriter('./my_graph', sess.graph)AttributeError: 'module' 对象没有属性 'FileWriter'
我也在终端中运行它,得到相同的结果:
[VansFannel@localhost ~]$ pythonPython 2.7.5(默认,2016 年 11 月 6 日,00:28:07)[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] 在 linux2 上输入帮助"、版权"、信用"或许可"以获取更多信息.>>>将张量流导入为 tfW tensorflow/core/platform/cpu_feature_guard.cc:95] TensorFlow 库未编译为使用 SSE4.2 指令,但这些指令可在您的机器上使用,并且可以加速 CPU 计算.W tensorflow/core/platform/cpu_feature_guard.cc:95] TensorFlow 库没有被编译为使用 AVX 指令,但这些在您的机器上可用并且可以加速 CPU 计算.>>>a = tf.constant(5, name="input_a")>>>b = tf.constant(3, name="input_b")>>>c = tf.mul(a, b, name="mul_c")>>>d = tf.add(a, b, name="add_d")>>>e = tf.add(c, d, name="add_e")>>>sess = tf.Session()>>>输出 = sess.run(e)>>>writer = tf.train.FileWriter('./my_graph', sess.graph)回溯(最近一次调用最后一次):文件<stdin>",第 1 行,位于 <module>AttributeError: 'module' 对象没有属性 'FileWriter'>>>
tf.train.SummaryWriter
已弃用,改为使用 tf.summary.FileWriter
.
它将在 2016-11-30 之后移除.更新说明:请切换到tf.summary.FileWriter
.界面和行为是一样的;这只是重命名.
<TF 官方迁移页面
> ✳︎ 包括所有当前已弃用/重命名的功能 ✳︎
I'm using Tensorflow version 0.12.head with Python 2.7 on a linux CentOS 7 and when I run this:
import tensorflow as tf
a = tf.constant(5, name="input_a")
b = tf.constant(3, name="input_b")
c = tf.mul(a, b, name="mul_c")
d = tf.add(a, b, name="add_d")
e = tf.add(c, d, name="add_e")
sess = tf.Session()
output = sess.run(e)
writer = tf.train.SummaryWriter('./my_graph', sess.graph)
I get this error:
AttributeError Traceback (most recent call last) <ipython-input-6-29c037e85eec> in <module>()
----> 1 writer = tf.train.SummaryWriter('./my_graph', sess.graph)
AttributeError: 'module' object has no attribute 'SummaryWriter'
I have run these two commands because there is bug issue on Github for the same problem:
>>> import six
>>> print(six.__version__)
1.10.0
>>> print(dir(six.moves.queue)) ['Empty', 'Full', 'LifoQueue', 'PriorityQueue', 'Queue', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_threading', '_time', 'deque', 'heapq']
>>> print(six.moves.queue.__file__) /usr/lib64/python2.7/Queue.pyc
I'm new in Python and in Tensorflow. Do you know how can I fix this error?
I have changed SummaryWriter
with FileWriter
:
writer = tf.train.FileWriter('./my_graph', sess.graph)
And I get the same error but with FileWriter
function:
AttributeError Traceback (most recent call last)
<ipython-input-8-daa50ea2b8f9> in <module>()
----> 1 writer = tf.train.FileWriter('./my_graph', sess.graph)
AttributeError: 'module' object has no attribute 'FileWriter'
I have also run it in a terminal and I get the same result:
[VansFannel@localhost ~]$ python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
>>> a = tf.constant(5, name="input_a")
>>> b = tf.constant(3, name="input_b")
>>> c = tf.mul(a, b, name="mul_c")
>>> d = tf.add(a, b, name="add_d")
>>> e = tf.add(c, d, name="add_e")
>>> sess = tf.Session()
>>> output = sess.run(e)
>>> writer = tf.train.FileWriter('./my_graph', sess.graph)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'FileWriter'
>>>
tf.train.SummaryWriter
is deprecated, instead use tf.summary.FileWriter
.
↳ Adding Summaries to Event Files
It will be removed after 2016-11-30. Instructions for updating: Please switch to
tf.summary.FileWriter
. The interface and behavior is the same; this is just a rename.
<TF Official Migration Page
> ✳︎ includes all current deprecated/renamed functions ✳︎
这篇关于'module' 对象没有属性 'SummaryWriter'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!