README.md 2.7 KB
Newer Older
Z
zenghsh3 已提交
1 2
[中文版](README_cn.md)

Z
zenghsh3 已提交
3
## Reproduce DQN, DoubleDQN, DuelingDQN model with Fluid version of PaddlePaddle
S
Shan Yi 已提交
4
Based on PaddlePaddle's next-generation API Fluid, the DQN model of deep reinforcement learning is reproduced, and the same level of indicators of the paper is reproduced in the classic Atari game. The model receives the image of the game as input, and uses the end-to-end model to directly predict the next step. The repository contains the following three types of models:
Z
zenghsh3 已提交
5
+ DQN in
6
[Human-level Control Through Deep Reinforcement Learning](http://www.nature.com/nature/journal/v518/n7540/full/nature14236.html)
Z
zenghsh3 已提交
7
+ DoubleDQN in:
8
[Deep Reinforcement Learning with Double Q-Learning](https://www.aaai.org/ocs/index.php/AAAI/AAAI16/paper/viewPaper/12389)
Z
zenghsh3 已提交
9
+ DuelingDQN in:
10
[Dueling Network Architectures for Deep Reinforcement Learning](http://proceedings.mlr.press/v48/wangf16.html)
11

Z
zenghsh3 已提交
12
## Atari benchmark & performance
S
Shan Yi 已提交
13 14 15 16

### Atari games introduction

Please see [here](https://gym.openai.com/envs/#atari) to know more about Atari game.
17

Z
zenghsh3 已提交
18
### Pong game result
S
Shan Yi 已提交
19

Z
zenghsh3 已提交
20
The average game rewards that can be obtained for the three models as the number of training steps changes during the training are as follows(about 3 hours/1 Million steps):
S
Shan Yi 已提交
21 22 23 24

<div align="center">
<img src="assets/dqn.png" width="600" height="300" alt="DQN result"></img>
</div>
25

Z
zenghsh3 已提交
26
## How to use
Z
zenghsh3 已提交
27
### Dependencies:
Z
zenghsh3 已提交
28 29 30 31
+ python2.7
+ gym
+ tqdm
+ opencv-python
32
+ paddlepaddle-gpu>=1.0.0
Z
zenghsh3 已提交
33
+ ale_python_interface
Z
zenghsh3 已提交
34

Z
zenghsh3 已提交
35
### Install Dependencies:
Z
zenghsh3 已提交
36 37 38 39 40 41 42
+ Install PaddlePaddle:
    recommended to compile and install PaddlePaddle from source code
+ Install other dependencies:
    ```
    pip install -r requirement.txt
    pip install gym[atari]
    ```
S
Shan Yi 已提交
43
    Install ale_python_interface, please see [here](https://github.com/mgbellemare/Arcade-Learning-Environment).
44

Z
zenghsh3 已提交
45
### Start Training:
Z
zenghsh3 已提交
46 47 48
```
# To train a model for Pong game with gpu (use DQN model as default)
python train.py --rom ./rom_files/pong.bin --use_cuda
49

Z
zenghsh3 已提交
50 51
# To train a model for Pong with DoubleDQN
python train.py --rom ./rom_files/pong.bin --use_cuda --alg DoubleDQN
52

Z
zenghsh3 已提交
53 54 55
# To train a model for Pong with DuelingDQN
python train.py --rom ./rom_files/pong.bin --use_cuda --alg DuelingDQN
```
56

S
Shan Yi 已提交
57
To train more games, you can install more rom files from [here](https://github.com/openai/atari-py/tree/master/atari_py/atari_roms).
58

Z
zenghsh3 已提交
59
### Start Testing:
Z
zenghsh3 已提交
60 61 62
```
# Play the game with saved best model and calculate the average rewards
python play.py --rom ./rom_files/pong.bin --use_cuda --model_path ./saved_model/DQN-pong
63

Z
zenghsh3 已提交
64 65 66
# Play the game with visualization
python play.py --rom ./rom_files/pong.bin --use_cuda --model_path ./saved_model/DQN-pong --viz 0.01
```
67
[Here](https://pan.baidu.com/s/1gIsbNw5V7tMeb74ojx-TMA) is saved models for Pong and Breakout games. You can use it to play the game directly.