README.md 2.3 KB
Newer Older
1
# 基于PaddlePaddle的Fluid版本复现DQN, DoubleDQN, DuelingDQN三个模型
T
TomorrowIsAnOtherDay 已提交
2
基于Paddle下一代API fluid复现了深度强化学习领域的DQN模型,在经典的Atari 游戏上复现了论文同等水平的指标,模型接收游戏的图像作为输入,采用端到端的模型直接预测下一步要执行的控制信号,本仓库一共包含以下3类模型。
3
+ DQN模型: 
4
[Human-level Control Through Deep Reinforcement Learning](http://www.nature.com/nature/journal/v518/n7540/full/nature14236.html)
5
+ DoubleDQN模型:
6
[Deep Reinforcement Learning with Double Q-Learning](https://www.aaai.org/ocs/index.php/AAAI/AAAI16/paper/viewPaper/12389)
7
+ DuelingDQN模型:
8
[Dueling Network Architectures for Deep Reinforcement Learning](http://proceedings.mlr.press/v48/wangf16.html)
9

T
TomorrowIsAnOtherDay 已提交
10
# 模型效果:Atari游戏表现
11
## [Atari游戏介绍](https://gym.openai.com/envs/#atari)
12

13
+ Pong游戏训练结果
14
![DQN result](assets/dqn.png)
15

16 17
# 使用教程
+ 依赖:
18 19 20
    + python2.7
    + gym
    + tqdm
21
    + opencv-python
Z
zenghsh3 已提交
22
    + paddlepaddle-gpu>=0.12.0 
Z
zenghsh3 已提交
23 24 25 26
    + ale_python_interface

+ 下载依赖:
    + 安装PaddlePaddle
Z
zenghsh3 已提交
27
    建议通过PaddlePaddle源码进行编译安装    
Z
zenghsh3 已提交
28
    + 下载其它依赖
29
    ```
30
    pip install -r requirement.txt 
Z
zenghsh3 已提交
31
    pip install gym[atari]
32
    ```
Z
zenghsh3 已提交
33
    安装ale_python_interface可以参考:https://github.com/mgbellemare/Arcade-Learning-Environment
34 35 36 37

+ 训练模型:
    ```
    # 使用GPU训练Pong游戏(默认使用DQN模型)
38
    python train.py --rom ./rom_files/pong.bin --use_cuda
39

40
    # 训练DoubleDQN模型
41
    python train.py --rom ./rom_files/pong.bin --use_cuda --alg DoubleDQN
42

43
    # 训练DuelingDQN模型
44 45
    python train.py --rom ./rom_files/pong.bin --use_cuda --alg DuelingDQN
    ```
46

47
    训练更多游戏,可以下载游戏rom从[这里](https://github.com/openai/atari-py/tree/master/atari_py/atari_roms)
48

49
+ 测试模型: 
50 51
    ```
    # Play the game with saved model and calculate the average rewards
52 53
    # 使用训练过程中保存的最好模型玩游戏,以及计算平均奖励(rewards) 
    python play.py --rom ./rom_files/pong.bin --use_cuda --model_path ./saved_model/DQN-pong
54

55 56
    # 以可视化的形式来玩游戏
    python play.py --rom ./rom_files/pong.bin --use_cuda --model_path ./saved_model/DQN-pong --viz 0.01
57
    ```