GithubHelp home page GithubHelp logo

shanhaoyu / deep-q-network-breakout Goto Github PK

View Code? Open in Web Editor NEW
31.0 1.0 14.0 973 KB

This is an implementation of Deep Q Learning (DQN) playing Breakout from OpenAI's gym with Keras.

Python 100.00%
keras reinforcement-learning dueling-dqn double-dqn

deep-q-network-breakout's Introduction

Deep-Q-Network--Breakout

This is the third assignment of ADLxMLDS course, NTU 2017 Fall, which is an implementation of Deep Q Learning (DQN) playing Breakout from OpenAI's gym with Keras.

Demo

I've implement deep reinforcement learning algorithm with Keras. In this project, the following techniques have been implemented:

  • Deep Q Learning
  • Double Q Learning
  • Dueling Network
  • Prioritized Experience Play

Here's the architecture overview of DQN model in this work:

The project is derived from an assignment of the course ADLxMLDS 2017 fall.

Requirements

The follow packages are required, you can install them with pip3 install [package]

  • opencv-python
  • gym
  • gym[atari]
  • tensorflow
  • keras
  • scipy

Setup

  • Training an agent to play atari game

    To train an agent playing Breakout with DQN, simply run

    python main.py --train_dqn

    To activate advanced algorithm such as Double DQN (DDQN)/ Dueling Network, you can run

    python main.py --train_dqn --ddqn True

    python main.py --train_dqn --dueling True

  • Test the agent's ability

    Before test the code, download the pretrained model from google drive, and put the model into ./pretrained_model/model.h5

    By running the following command, you can get agent's average score in 100 episode

    python test.py --test_dqn

    Testing can be performed with the pretrained model training by default or with the model you trained by adding argument --test_dqn_model_path [your model path]

    To visualize the gaming progress, add --do_render to the end. You can also save it to vedio with --video_dir [path to save] (set smaller testing episode before doing so)

    python test.py --test_dqn --do_render

    or

    python test.py --test_dqn --video_dir [path]

References

deep-q-network-breakout's People

Contributors

shanhaoyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

deep-q-network-breakout's Issues

dqn_300.h5

Thank you very much sharing the repo. I have tried to use your model but I am getting the following error.

tensorflow.python.framework.errors_impl.UnknownError: FindFirstFile failed for: ./data/Breakout/dqn_300.h5 : The directory name is invalid.
; Unknown error

dueling network failed. I have no idea what is wrong

(venv_deep-q-network-breakout) (base) w-mbas-9293:Deep-Q-Network-Breakout jesusramos$ python main.py --train_dqn --dueling True
/Users/rams/AIs/venv_deep-q-network-breakout/lib/python3.5/site-packages/gym/logger.py:30: UserWarning: WARN: gym.spaces.Box autodetected dtype as <class 'numpy.uint8'>. Please provide explicit dtype.
warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Using TensorFlow backend.
2019-02-07 14:45:28.417123: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
File "main.py", line 39, in
run(args)
File "main.py", line 28, in run
agent = Agent_DQN(env, args)
File "/Users/jesusramos/AIs/Deep-Q-Network-Breakout/agent_dir/agent_dqn.py", line 91, in init
self.q_network = self.build_network()
File "/Users/rams/AIs/Deep-Q-Network-Breakout/agent_dir/agent_dqn.py", line 170, in build_network
output_shape = self.num_actions)
TypeError: 'module' object is not callable

Training

Thank you very much for sharing your wonderful project!

I'd like to train my own agents with your code and I am curious how long you trained the model shared in your google drive. How many episodes and frames did you train it? On which hardware did you train it (GPU/RAM)? How many hours did the training take?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.