我是新手,我真的需要你帮助在python中使用tensorflow。
我想使用此link in github构建具有序列序列的chatbot。但是当我开始运行此代码python 03-Twitter-chatbot.py
(在下载然后提取数据集和read the related article之后)程序没有运行。并显示以下错误消息:
<log> Building Graph Traceback (most recent call last):
File "03-Twitter-chatbot.py", line 33, in <module>
num_layers=3
File "D:\Temporary\abang nitip\Directory\practical_seq2seq-master\seq2seq_wrapper.py", line 79, in __init__ __graph__()
File "D:\Temporary\abang nitip\Directory\practical_seq2seq-master\seq2seq_wrapper.py", line 45, in __graph__ basic_cell = tf.contrib.rnn.core_rnn_cell.DropoutWrapper(AttributeError: module 'tensorflow.contrib.rnn' has no attribute 'core_rnn_cell'
我想知道发生了什么,我开始运行另一个code错误是不同的,它说我的tensorflow无法导入basic_rnn或seq2seq 。然后我在cmd:
中运行此代码检查了我的张量流import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
输入sess = tf.Session()
后会出现如下消息:
2017-07-18 13:46:37.730648: W C:\tf_jenkins\home\workspace\nightly-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-07-18 13:46:37.731648: W C:\tf_jenkins\home\workspace\nightly-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
我不知道如何解决这个问题,我只是猜测也许我的张量流量运行不好。我使用tensorflow在我的电脑中使用spesification Windows 7旗舰版 - 64位,Python 3.5.2 。
请帮助我克服这一点。 对于我糟糕的英语我很抱歉
答案 0 :(得分:0)
正如Venky所说,这是一个向后兼容的问题。
如果你只想让它工作,你应该降级到tensorflow 0.12.0。您共享的github project已经指定了它所基于的tensowflow版本(0.12)。你可以用一个简单的来做到这一点
class Player(pg.sprite.Sprite):
def __init__(self):
pg.sprite.Sprite.__init__(self)
self.counter = 0 # Index of the current image.
# Assign the first player image.
self.image = player_images[self.counter]
self.pos = vec(WIDTH - 650, HEIGHT - 700)
# Now get_rect works. Set the center or topleft to self.pos.
self.rect = self.image.get_rect(center=self.pos)
self.standing = False
self.vel = vec(0, 0)
self.acc = vec(0, 0)
def update(self):
self.acc = vec(0, PLAYER_GRAVITY)
keystate = pg.key.get_pressed()
if keystate[pg.K_LEFT]:
# Increment the counter.
self.counter = (self.counter + 1) % len(player_images)
# And finally change the image.
self.image = player_images[self.counter]
如果您想了解张量流中seq2seq的更多详细信息,this current google official seq2seq tutorial可能是更好的选择。官方教程几天前刚刚发布,并介绍了一些新的tf功能,如'dynamic_rnn'。
正如评论中所述,git repo更新了代码而没有更新兼容性信息,这意味着你不清楚你需要什么是正确的版本。您应该尝试最近的tensorflow版本(1.1或1.2)。