零基础10分钟运行DQN图文教程 Playing Flappy Bird Using Deep Reinforcement Learning (Based on Deep Q Learning DQN
文件下载
链接:http://pan.baidu.com/s/1jH9ItTW 密码:0pmq
文件列表
Anaconda3-4.2.0-Windows-x86_64.exe (python3.5.2)
pycharm-community-2017.2.4.exe
tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl 或 (tensorflow_cpu-1.1.0-cp35-cp35m-win_amd64.whl),1.1.0以上版本
pygame-1.9.3-cp35-cp35m-win_amd64.whl
安装顺序:
联想笔记本电脑T430、64位机
1. win7旗舰sp1
2.Anaconda3-4.2.0-Windows-x86_64.exe
3. pycharm-community-2017.2.4.exe
4. tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl
5. pip install pygame
系统会自动匹配和python对应的版本
或者 pip install c:\pygame-1.9.3-cp35-cp35m-win_amd64.whl
完整项目下载
https://github.com/songrotek/DRL-FlappyBird
说明:python2.x版本,在python3.x环境需要修改部分函数命名和使用方法。
运行
python C:\DRL-FlappyBird-master\FlappyBirdDQN.py
效果
运行说明
随着训练,小鸟飞行距离越来越远。
训练需要时长比较长。
问题和解决方法总结
问题1:
File "C:\DRL-FlappyBird-master\BrainDQN_Nature.py", line 155
print "TIMESTEP", self.timeStep, "/ STATE", state, \
^
SyntaxError: Missing parentheses in call to 'print'
print在python3.x里面 加(),这样print()
问题2:
AttributeError: 'itertools.cycle' object has no attribute 'next'
https://stackoverflow.com/questions/5237611/itertools-cycle-next
iter.next()
was
removed in python 3. Use next(iter)
instead.
So in your example change itertools.cycle().next()
to next(itertools.cycle())
There is a good
example here along with various other porting to python 3 tips. It also compares various other next()
idioms
in python 2.x vs python 3.x
wrapped_flappy_bird.py
#self.playerIndex = PLAYER_INDEX_GEN.next() self.playerIndex = next(PLAYER_INDEX_GEN)
问题3:
File "C:\DRL-FlappyBird-master\game\wrapped_flappy_bird.py", line 222, in pixelCollision
for x in xrange(rect.width):
NameError: name 'xrange' is not defined
xrange 修改wierange
问题4:
WARNING:tensorflow:From C:\DRL-FlappyBird-master\BrainDQN_Nature.py:45: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02. Instructions for updating: Use `tf.global_variables_initializer` instead.
#self.session.run(tf.initialize_all_variables()) self.session.run(tf.global_variables_initializer)
问题5:
ImportError: No module named 'pygame'
pip install pygame 会自动匹配和python对应的版本
或者 pip install c:\pygame-1.9.3-cp35-cp35m-win_amd64.whl
遇到问题、分享经验欢迎加入QQ群:452205574