AlphaZero.jl

授权协议 MIT License
开发语言
所属分类 神经网络/人工智能、 机器学习/深度学习
软件类型 开源软件
地区 不详
投 递 者 濮阳赞
操作系统 跨平台
开源组织
适用人群 未知
 软件概览


This package provides a generic, simple and fast implementation ofDeepmind's AlphaZero algorithm:

  • The core algorithm is only 2,000 lines of pure, hackable Julia code.
  • Generic interfaces make it easy to add support for new games or new learningframeworks.
  • Being between one and two orders of magnitude faster than competingalternatives written in Python, this implementation enables to solvenontrivial games on a standard desktop computer with a GPU.
  • The same agent can be trained on acluster of machines as easily as on asingle computer and without modifying a single line of code.

Why should I care about AlphaZero?

Beyond its much publicized success in attaining superhuman level at gamessuch as Chess and Go, DeepMind's AlphaZero algorithm illustrates a moregeneral methodology of combining learning and search to explore largecombinatorial spaces effectively. We believe that this methodology canhave exciting applications in many different research areas.

Why should I care about this implementation?

Because AlphaZero is resource-hungry, successful open-sourceimplementations (such as Leela Zero)are written in low-level languages (such as C++) and optimized for highlydistributed computing environments.This makes them hardly accessible for students, researchers and hackers.

The motivation for this project is to provide an implementation ofAlphaZero that is simple enough to be widely accessible, while also beingsufficiently powerful and fast to enable meaningful experiments on limitedcomputing resources.We found the Julia language to be instrumental in achieving this goal.

Training a Connect Four Agent

To download AlphaZero.jl and start training a Connect Four agent, just run:

export GKSwstype=100  # To avoid an occasional GR bug
git clone https://github.com/jonathan-laurent/AlphaZero.jl.git
cd AlphaZero.jl
julia --project -e 'import Pkg; Pkg.instantiate()'
julia --project -e 'using AlphaZero; Scripts.train("connect-four")'

Each training iteration takes about one hour on a desktopcomputer with an Intel Core i5 9600K processor and an 8GB Nvidia RTX2070 GPU. We plot below the evolution of the win rate of our AlphaZero agent against two baselines (a vanilla MCTS baseline and a minmax agent that plans at depth 5 using a handcrafted heuristic):



Note that the AlphaZero agent is not exposed to the baselines during training andlearns purely from self-play, without any form of supervision or prior knowledge.

We also evaluate the performances of the neural network alone against the samebaselines. Instead of plugging it into MCTS, we play the action that isassigned the highest prior probability at each state:



Unsurprisingly, the network alone is initially unable to win a single game.However, it ends up significantly stronger than the minmax baseline despite notbeing able to perform any search.

For more information on training a Connect Four agent using AlphaZero.jl, see our full tutorial.

Resources

Contributors

  • Jonathan Laurent: main developer
  • Pavel Dimens: logo design
  • Marek Kaluba: hyperparameters tuning for the grid-world example
  • Michał Łukomski: Mancala example, OpenSpiel wrapper
  • Johannes Fischer: documentation improvements

Contributions to AlphaZero.jl are most welcome. Many contribution ideas are available in our contribution guide.Please do not hesitate to open a Githubissue to shareany idea, feedback or suggestion.

Supporting and Citing

If you want to support this project and help it gain visibility, please consider starringthe repository. Doing well on such metrics may also help us secure academic funding in thefuture. Also, if you use this software as part of your research, we would appreciate thatyou include the following citation in your paper.

Related Julia Projects

  • AlphaGPU.jl: an AlphaZero implementation inspired from the "Scaling Scaling Laws with Board Games" paper, where almost everything happens on GPU (including the core MCTS logic). This implementation trades off some genericity and flexibility in exchange for unbeatable performances when used with small neural networks and environments that support batch-simulation on GPU.
  • ReinforcementLearning.jl: a reinforcement learning framework that leverages Julia's multiple dispatch to offer highly composable environments, algorithms and components. Future releases of AlphaZero.jl may build on this framework, as it gains better support for multithreaded and distributed RL.
  • POMDPs.jl: a fast, elegant and well-designed framework for working with partially observable Markov decisions processes.

Acknowledgements

This material is based upon work supported by the United States Air Force andDARPA under Contract No. FA9550-16-1-0288 and FA8750-18-C-0092.Any opinions, findings and conclusions or recommendations expressed in this material arethose of the author(s) and do not necessarily reflect the views of the United StatesAir Force and DARPA.