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
Hashes for mu_alpha_zero_library-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a71e4ac9758dd87cba9faf63170c6f67ccc1e4760a97ab4d673ce68f0a4e39a9 |
|
MD5 | 3cd7584ae20593254033660410bf6aad |
|
BLAKE2b-256 | d6634334d5ba182662e41fbee8a93688f609bbe3b3a7373235a2f230738d2cda |
Hashes for mu_alpha_zero_library-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9854e6c574dfdd740a16e98276926015b51c2d062d344a9d53513eb28096944c |
|
MD5 | a8ebe585ff1a562125fb58499ac9f5b6 |
|
BLAKE2b-256 | 569ccda089f1da7d0204bc98520d6d361b6d6edfb00e6013d17b8f3ce657c728 |