Giter Site home page Giter Site logo

rostigerdagmer / muzero Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michaelnny/muzero

0.0 0.0 0.0 50.06 MB

A PyTorch implementation of DeepMind's MuZero agent

License: Apache License 2.0

Shell 0.13% Python 68.49% Jupyter Notebook 31.38%

muzero's Introduction

MuZero

A PyTorch implementation of DeepMind's MuZero agent.

Content

Environment and Requirements

  • Python 3.9.12
  • pip 22.0.3
  • PyTorch 1.11.0
  • gym 0.23.1
  • numpy 1.21.6

Code Structure

  • each of the (atari, classic, gomoku, tictactoe) directory contains the following modules:
    • run_training.py trains the agent for a specific game/control problem.
    • eval_agent.py evaluate the trained agent by loading from checkpoint.
  • config.py contains the MuZero configuration for different game/control problem.
  • games directory contains the custom Gomoku and Tic-Tac-Toe board game env implemented with openAI Gym.
  • gym_env.py contains openAI Gym wrappers for both Atari and classic control problem.
  • mcts.py contains the MCTS node and UCT tree-search algorithm.
  • pipeline.py contains the functions to run self-play, training, and evaluation loops.
  • util.py contains the functions for value and reward target transform and rescaling.
  • replay.py contains the experience replay class.
  • trackers.py contains the functions to monitoring training progress using Tensorboard.

Author's Notes

  • Only tested on classic control tasks and Tic-Tac-Toe.
  • Hyper-parameters are not fine-tuned.
  • We use uniform random replay as it seems to be better than prioritized replay.

Quick Start

Install required packages on Mac

# install homebrew, skip this step if already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# upgrade pip
python3 -m pip install --upgrade pip setuptools

# install swig which is required for box-2d
brew install swig

# install ffmpeg for recording agent self-play
brew install ffmpeg

# install snappy for compress numpy.array on M1 mac
brew install snappy
CPPFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" pip3 install python-snappy

pip3 install -r requirements.txt

Install required packages on Ubuntu Linux

# install swig which is required for box-2d
sudo apt install swig

# install ffmpeg for recording agent self-play
sudo apt-get install ffmpeg

# upgrade pip
python3 -m pip install --upgrade pip setuptools

pip3 install -r requirements.txt

Start Training

# Training on classic control problems
python3 -m muzero.classic.run_training
python3 -m muzero.classic.run_training --environment_name=LunarLander-v2

# Training on Atari
python3 -m muzero.atari.run_training

# Training on Tic-Tac-Toe
python3 -m muzero.tictactoe.run_training

# Training on Gomoku
python3 -m muzero.gomoku.run_training

Monitoring with Tensorboard

tensorboard --logdir=runs

Screenshots Tic-Tac-Toe

  • Training performance measured in Elo rating Training performance

Screenshots CartPole

Training performance

Screenshots LunarLander

Training performance

Evaluate Agents

Note for board games with two players, the evaluation will run in MuZero vs. MuZero mode.

To start play the game, make sure you have a valid checkpoint file and run the following command

python3 -m muzero.tictactoe.eval_agent

python3 -m muzero.classic.eval_agent

Reference Papers

Reference Code

License

This project is licensed under the Apache License, Version 2.0 (the "License") see the LICENSE file for details

Citing our work

If you reference or use our project in your research, please cite:

@software{muzero2022github,
  title = {{MuZero}: A PyTorch implementation of DeepMind's MuZero agent},
  author = {Michael Hu},
  url = {https://github.com/michaelnny/muzero},
  version = {1.0.0},
  year = {2022},
}

muzero's People

Contributors

michaelnny avatar rostigerdagmer 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.