GithubHelp home page GithubHelp logo

tedrepo / hierarchical-drl-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hipoglucido/hierarchical-drl-tensorflow

0.0 2.0 0.0 54.44 MB

Hierarchical Reinforcement Learning on Space Fortress

Makefile 0.10% Python 12.65% C 6.09% C++ 0.02% Jupyter Notebook 81.15%

hierarchical-drl-tensorflow's Introduction

Hierarchical Reinforcement Learning

The purpose of this project is to use Hierarchical Deep Reinforcement Learning to solve the Space Fortress Game using Tensorflow. As a toy example a simple deterministic MDP environment is created, in which a goal directed-behaviour is required.

The DQN will be used as baseline with the extensions Double Q learning, Dueling architecture and Prioritized Experience Replay. This will be compared with another extension to handle options as actions via h-DQN.

Reference code:

Set up

Space Fortress libraries such as Cairo need to be installed as it is described in this repo. Once the game has been compiled, the file(s) sf_frame_lib_mines0.so and sf_frame_lib_mines1.so should be located in Environments/SpaceFortress/gym_space_fortress/envs/space_fortress/shared This project is implemented in python 3.6 using tensorflow 1.8.

Examples

Play as a human to see if the game is ready:

python main.py --agent_type=human --env_name=SF-v0 --render_delay=42

Train an DQN agent

python main.py --agent_type=dqn --env_name=SF-v0 --scale=5000 --double_q=1 --dueling=1 --pmemory=1 --architecture=128-128-128

When training a Hierarchical DQN agent we can set the desired DQN extensions separately for the meta-controller and controller using the prefixes 'mc' and 'c' respectively:

python main.py --agent_type=hdqn --env_name=SF-v0 --scale=5000 --mc_double_q=1 --c_dueling=1 --c_pmemory=0 --goal_group=2

The hyperparameters available from command line are listed in main.py and will overwrite the default values of all the available hyperparameters, which are listed in configuration.py.

The training will automatically generate the tensorboard logs and checkpoints of the network/s weights.

It will record videos of the last steps of the game. For each run, in the logs folder the files watch0 and record0 are created. These can be renamed back and forth to watch1 (to visualize the training in a window) and record1 (to generate videos) at any point during training.

Goals

If using the hDQN version, one may want to define a new set of goals. Each set of goals is defined as a list of goal names (strings) in the goal_groups dict in constants.py. Sets of goals can be defined by 1) changing such dict and 2) add the functionality to check if the goal is accomplished in the method is_achieved of the class Goal.

Others

The project is not finished because I still have to run some experiments. Here is a gameplay of the agent https://www.youtube.com/watch?v=-PKxXXtKZdQ

This projects makes an extensive use of tensorboard to visualize various learning metrics alt text

One graph of the Hierarchical Reinforcement Learning agent: alt text

hierarchical-drl-tensorflow's People

Contributors

ethanmacdonald avatar hipoglucido avatar richielo avatar

Watchers

 avatar  avatar

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.