Coder Social home page Coder Social logo

cycraig / mp-dqn Goto Github PK

View Code? Open in Web Editor NEW
183.0 5.0 49.0 54 KB

Source code for the dissertation: "Multi-Pass Deep Q-Networks for Reinforcement Learning with Parameterised Action Spaces"

License: MIT License

Python 100.00%
deep-reinforcement-learning parameterised-action-spaces parameterised-actions

mp-dqn's Introduction

Multi-Pass Deep Q-Networks

This repository includes several reinforcement learning algorithms for parameterised action space MDPs:

  1. P-DQN [Xiong et al. 2018]

  2. PA-DDPG [Hausknecht & Stone 2016]

  3. Q-PAMDP [Masson et al. 2016]

Multi-Pass Deep Q-Networks (MP-DQN) fixes the over-paramaterisation problem of P-DQN by splitting the action-parameter inputs to the Q-network using several passes (in a parallel batch). Split Deep Q-Networks (SP-DQN) is a much slower solution which uses multiple Q-networks with/without shared feature-extraction layers. A weighted-indexed action-parameter loss function is also provided for P-DQN.

Dependencies

  • Python 3.5+ (tested with 3.5 and 3.6)
  • pytorch 0.4.1 (1.0+ should work but will be slower)
  • gym 0.10.5
  • numpy
  • click

Domains

Experiment scripts are provided to run each algorithm on the following domains with parameterised actions:

The simplest installation method for the above OpenAI Gym environments is as follows:

pip install -e git+https://github.com/cycraig/gym-platform#egg=gym_platform
pip install -e git+https://github.com/cycraig/gym-goal#egg=gym_goal
pip install -e git+https://github.com/cycraig/gym-soccer#egg=gym_soccer 

If something goes wrong, follow the installation instructions given by the repositories above. Note that gym-soccer has been updated for a later gym version and the reward function changed to reflect the one used in the code by Hausknecht & Stone [2016] (https://github.com/mhauskn/dqn-hfo). So use the one linked above rather than the OpenAI repository.

Example Usage

Each run file has default flags in place, view the run_domain_algorithm.py files for more information. The click flags are configured to make it easier to run experiments and hyper-parameter searches in batches, which is better for scripts but makes it more annoying to type out.

To run vanilla P-DQN on the Platform domain with default flags:

python run_platform_pdqn.py 

SP-DQN on the Robot Soccer Goal domain, rendering each episode:

python run_goal_pdqn.py --split True --visualise True --render-freq 1

MP-DQN on Half Field Offense with four hidden layers (note no spaces) and the weighted-indexed loss function:

python run_soccer_pdqn.py --multipass True --layers [1024,512,256,128] --weighted True --indexed True

Citing

If this repository has helped your research, please cite the following:

@article{bester2019mpdqn,
	author    = {Bester, Craig J. and James, Steven D. and Konidaris, George D.},
	title     = {Multi-Pass {Q}-Networks for Deep Reinforcement Learning with Parameterised Action Spaces},
	journal   = {arXiv preprint arXiv:1905.04388},
	year      = {2019},
	archivePrefix = {arXiv},
	eprinttype    = {arxiv},
	eprint    = {1905.04388},
	url       = {http://arxiv.org/abs/1905.04388},
}

mp-dqn's People

Contributors

cycraig 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mp-dqn's Issues

MP-DQN using Dueling Network

Hi!

For my Master's thesis, I'm looking to use the MP-DQN algorithm in order to solve a problem. However, I'd like to use a dueling network to speed up convergence. With the regular P-DQN algorithm, this was quite easily accomplished, but it is not as intuitive with the MP-DQN algorithm. For the advantage function, the diagonal of the output of the multi-pass works as expected since it refers to the numbers of actions, but it does not make sense for the value function, since that is not dependent on the action parameters, but just a single value representing the value of the state.

There are a few things that could be done. One thing is to do as the P-DQN and have the value function part of the dueling network be dependent on all action parameters. Another thing is to have it be dependent on no action parameters, but this requires the dueling network to be split up more (since the input dimensions for the first fully connected layer would be different for the advantage function and the value function). Finally, one could still perform the multi-pass on the value part, and take the mean of the outputs or something similar.

I don't really know what the smartest choice here is. Intuitively, it feels as if the value function should have nothing to do with the action parameters. Given your knowledge with the MP-DQN, do you have any ideas as to what might be a smart solution?

Thank you! (Also thank you very much for making your code open-sourced!)

Debugger not working

/home/tj/anaconda3/envs/p-dqn/bin/python3 /snap/pycharm-professional/171/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 40821 --file /home/tj/PycharmProjects/MP-DQN/run_soccer_qpamdp.py
pydev debugger: process 7349 is connecting

Connected to pydev debugger (build 192.7142.56)
/home/tj/anaconda3/envs/p-dqn/lib/python3.6/site-packages/hfo_py/bin/HFO
Starting server with command: /home/tj/anaconda3/envs/p-dqn/lib/python3.6/site-packages/hfo_py/bin/HFO --headless --frames-per-trial 500 --offense-agents 1 --defense-agents 0 --offense-npcs 0 --defense-npcs 0 --port 47115 --offense-on-ball 0 --seed -1 --ball-x-min 0.000000 --ball-x-max 0.200000 --log-dir log --fullstate --no-logging
usage: HFO [-h] [--headless] [--trials NUMTRIALS] [--frames NUMFRAMES]
           [--frames-per-trial MAXFRAMESPERTRIAL]
           [--untouched-time MAXUNTOUCHEDTIME]
           [--offense-agents OFFENSEAGENTS] [--defense-agents DEFENSEAGENTS]
           [--offense-npcs OFFENSENPCS] [--defense-npcs DEFENSENPCS]
           [--agent-play-goalie] [--offense-team OFFENSETEAM]
           [--defense-team DEFENSETEAM] [--no-sync] [--port PORT]
           [--no-logging] [--hfo-logging] [--log-dir LOGDIR] [--record]
           [--offense-on-ball OFFENSEONBALL] [--fullstate] [--seed SEED]
           [--message-size MESSAGESIZE] [--ball-x-min MIN_BALL_X]
           [--ball-x-max MAX_BALL_X] [--ball-y-min MIN_BALL_Y]
           [--ball-y-max MAX_BALL_Y] [--verbose] [--deterministic]
HFO: error: argument --frames-per-trial: invalid int value: '/snap/pycharm-professional/171/helpers/pydev/pydevd.py'
******************************************************************
 librcsc 4.1.0
 Copyright 2000 - 2007. Hidehisa Akiyama.
 Copyright 2007 - 2011. Hidehisa Akiyama and Hiroki Shimora
 All rights reserved.
******************************************************************
[ConnectToServer] Server Down!
 -1: waited 5 seconds. server down??

Process finished with exit code 1

If it runs run_psoccer_pdqn.py , the code will work properly, but debugging will result in the above error. How can I debug correctly?

Questions about class SARSA(lambda)

Hello. I have a few questions.
1, What the effect of variable "shrink" in the class "SarsaLambdaAgent"? And Can I use other basis instead, like the polynomial basis?
2, Why do you scale step size of SARSA agent? Can I use a fixed one instead?

How to finetune?

I have trained a model for "soccer pdqn", and I want to finetune a new work based on the trained model, what should I do?

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.