A Tensorflow implementation of a Deep Q Network (DQN) for playing Atari games.
Trained on OpenAI Gym Atari environments.
Based on Human-Level Control through Deep Reinforcement Learning. This implementation includes the improvements to the original DQN detailed in the above paper, namely:
- Larger network
- Longer training
- Target network
- Huber loss
Note: Versions stated are the versions I used, however this will still likely work with other versions.
- Ubuntu 16.04 (Atari envs will only work 'out of the box' on Linux)
- python 3.5
- OpenAI Gym 0.10.8 (See link for installation instructions + dependencies)
- tensorflow-gpu 1.5.0
- numpy 1.15.2
- scipy 1.1.0
- opencv-python 3.4.0
- inotify-tools 3.14
The default environment is 'BreakoutDeterministic-v4'. To use a different environment simply pass the environment in via the --env
argument when running the following files.
$ python train.py
This will train the DQN on the specified environment and periodically save checkpoints to the /ckpts
folder.
$ ./run_every_new_ckpt.sh
This shell script should be run alongside the training script, allowing to periodically test the latest network as it trains. This script will monitor the /ckpts
folder and run the test.py
script on the latest checkpoint every time a new checkpoint is saved.
$ python play.py
Once we have a trained network, we can visualise its performance in the game environment by running play.py
. This will play the game on screen using the trained network.
Result of training the DQN on the 'BreakoutDeterministic-v4' environment:
- Playing Atari with Deep Reinforcement Learning
- Human-Level Control through Deep Reinforcement Learning
- Experience replay implementation
MIT License