Library for running and training MuZero and AlphaZero models.
Project description
MuAlphaZeroLibrary
Introduction
This is a library for training and using the MuZero and AlphaZero algorithms. The following features are currently implmented:
- MuZero and AlphaZero algorithms
- MuZero paper: Mastering Atari, Go, Chess and Shogi by Planning with a Learned Model
- AlphaZero paper: Mastering the game of Go without human knowledge
- Customizable games and networks
- Training and playing
- Saving and loading models
- Checkpoints and logging
- Parallel self-play
- Parallel hyperparameter search
📚 Documentation 📚
To see the project documentation, check the wiki page.
❗ Get started ❗
Linux Dependencies
To install the library on Linux, you will need dependencies to build mysqlclient. Check mysqlclient for a command to install dependencies on your system.
Python dependencies
The library is built using python3.11, which it is the only tested version. It is recommended that you use the 3.11.* version of python, because of significant speed improvements.
To see the entire list of dependencies, check the requirements.txt file.
Installation
After installing the dependencies, you can install the library using pip:
pip install mu_alpha_zero_library
⚡ Quick example ⚡
Here is a quick example of how to train a MuZero algorithm to play the atari game of DonkeyKong.
To define our custom game we can subsclass the abstract class MuZeroGame. See examples/donkey_kong.py for an example of how to do this.
Then we can define a MuZeroConfig object to define the hyperparameters of the MuZero algorithm:
from mu_alpha_zero.config import MuZeroConfig
config = MuZeroConfig()
# You can change all the hyperparameters here, for example:
config.num_simulations = 800
Finally, we can train the MuZero algorithm:
from mu_alpha_zero import MuZero
from mu_alpha_zero import MuZeroNet
from mu_alpha_zero.mem_buffer import MemBuffer
mz = MuZero(DonkeyKongGame()) # Import your own game.
memory = MemBuffer(config.max_buffer_size)
mz.create_new(config,MuZeroNet,memory,headless=True)
mz.train()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mu_alpha_zero_library-1.0.9.6.tar.gz
.
File metadata
- Download URL: mu_alpha_zero_library-1.0.9.6.tar.gz
- Upload date:
- Size: 66.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d583775f086bd030ffcff0851991841cc42f244296162c764c904831e2e44bd6 |
|
MD5 | 1923af2ab474d2b964a203450a2386cc |
|
BLAKE2b-256 | 85896d975789250e0865094c8ed4447cc1e4abb5803d310300f5f8400a66404d |
File details
Details for the file mu_alpha_zero_library-1.0.9.6-py3-none-any.whl
.
File metadata
- Download URL: mu_alpha_zero_library-1.0.9.6-py3-none-any.whl
- Upload date:
- Size: 82.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57c3a575afc70df4349b08168f7eddf959af4da6f5f5f54e4c69c9eae35f9226 |
|
MD5 | 6f292557643292543d302f14a5261032 |
|
BLAKE2b-256 | 9025ef15b3f7709ac997cef1ec49bbb3f7d1ee3982b2a1d19baa9e72db76c06c |