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

# Reproduce DQN, DoubleDQN, DuelingDQN model with Fluid version of PaddlePaddle
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.
+ 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 13
# Atari benchmark & performance
## [Atari games introduction](https://gym.openai.com/envs/#atari)
14

Z
zenghsh3 已提交
15
+ Pong game result
16
![DQN result](assets/dqn.png)
17

Z
zenghsh3 已提交
18 19
# How to use
+ Dependencies:
20 21 22
    + python2.7
    + gym
    + tqdm
23
    + opencv-python
Z
zenghsh3 已提交
24
    + paddlepaddle-gpu>=0.12.0
Z
zenghsh3 已提交
25 26
    + ale_python_interface

Z
zenghsh3 已提交
27
+ Install Dependencies:
Z
zenghsh3 已提交
28 29
    + Install PaddlePaddle:
        recommended to compile and install PaddlePaddle from source code
Z
zenghsh3 已提交
30
    + Install other dependencies:
Z
zenghsh3 已提交
31 32 33 34 35
        ```
        pip install -r requirement.txt 
        pip install gym[atari]
        ```
        Install ale_python_interface, can reference:https://github.com/mgbellemare/Arcade-Learning-Environment
Z
zenghsh3 已提交
36

37

Z
zenghsh3 已提交
38
+ Start Training:
39
    ```
Z
zenghsh3 已提交
40
    # To train a model for Pong game with gpu (use DQN model as default)
41
    python train.py --rom ./rom_files/pong.bin --use_cuda
42

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

Z
zenghsh3 已提交
46
    # To train a model for Pong with DuelingDQN
47 48
    python train.py --rom ./rom_files/pong.bin --use_cuda --alg DuelingDQN
    ```
49

Z
zenghsh3 已提交
50
    To train more games, can install more rom files from [here](https://github.com/openai/atari-py/tree/master/atari_py/atari_roms)
51

Z
zenghsh3 已提交
52
+ Start Testing:
53
    ```
Z
zenghsh3 已提交
54
    # Play the game with saved best model and calculate the average rewards
55
    python play.py --rom ./rom_files/pong.bin --use_cuda --model_path ./saved_model/DQN-pong
56

Z
zenghsh3 已提交
57
    # Play the game with visualization
58
    python play.py --rom ./rom_files/pong.bin --use_cuda --model_path ./saved_model/DQN-pong --viz 0.01
59
    ```