1/21
MuZero
Mastering Atari, Go, Chess and Shogi by Planning with a
Learned Model
NSE ML+Security Reading Group
Kim Hammar
kimham@kth.se
Division of Network and Systems Engineering
KTH Royal Institute of Technology
April 23, 2021
2/21
The Context and Key Points of the Paper
I MuZero is a model-based RL Algorithm
I Target domain: Games (Atari, Go, Chess..)
I A function-approximation approach to model-learning
I Extension to the Alpha-Series: AlphaGo, AlphaZero, ...
MuZero Agent
Observations rt+1
Board features ∈ RK×19×19 Reward ∈ [−1, 1]
at+1
3/21
The Context and Key Points of the Paper
Deep-Q-Network
Playing Atari
Nature, 14k citations
2015
AlphaGo
Nature, 10k citations
2016
AlphaGo Zero
Nature, 5.2k citations
2017
Alpha Zero
Science, 1.3k citations
2018 Alpha Star
Nature
2019, 800 citations
MuZero
Nature
2020, 300 citations
4/21
Outline
I Background
I Why Games
I The Alpha Series
I AlphaGo
I AlphaGo Zero
I The MuZero Algorithm
I Limitations
I Limitations of MuZero
I Applications to Security?
I Conclusions
5/21
Background: Why Games
b0
x0,1
x0,2
x0,3
b1
x1,1
x1,2
x1,3
ŷ
Agent
Environment
Action
a
t
rt
st
st+1
rt+1
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
Ply 1
Ply 2
Ply 3
Depth = 3
Branching factor = 3
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
VA LV E
R
AI & Machine Learning Games
Why Combine the two?
5/21
Background: Why Games
b0
x0,1
x0,2
x0,3
b1
x1,1
x1,2
x1,3
ŷ
Agent
Environment
Action
a
t
rt
st
st+1
rt+1
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
Ply 1
Ply 2
Ply 3
Depth = 3
Branching factor = 3
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
VA LV E
R
AI & Machine Learning Games
Why Combine the two?
I AI & Games have a long history (Turing ’50& Minsky 60’)
I Simple to evaluate, reproducible, controllable, quick feedback
loop
I Common benchmark for the research community
6/21
Background: 1997 DeepBlue1
vs Kasparov
1
Murray Campbell, A. Joseph Hoane, and Feng-hsiung Hsu. “Deep Blue”. In: Artif. Intell. 134.1–2 (Jan.
2002), 57–83. issn: 0004-3702. doi: 10.1016/S0004-3702(01)00129-1. url:
https://doi.org/10.1016/S0004-3702(01)00129-1.
7/21
Background: 1992 Tesauro’s TD-Gammon2
2
Gerald Tesauro. “TD-Gammon, a Self-Teaching Backgammon Program, Achieves Master-Level Play”. In:
Neural Comput. 6.2 (Mar. 1994), 215–219. issn: 0899-7667. doi: 10.1162/neco.1994.6.2.215. url:
https://doi.org/10.1162/neco.1994.6.2.215.
8/21
Background: 1959 Arthur Samuel’s Checkers Player3
3
A. L. Samuel. “Some Studies in Machine Learning Using the Game of Checkers”. In: IBM J. Res. Dev. 3.3
(July 1959), 210–229. issn: 0018-8646. doi: 10.1147/rd.33.0210. url:
https://doi.org/10.1147/rd.33.0210, A. L. Samuel. “Some Studies in Machine Learning Using the Game of
Checkers”. In: IBM J. Res. Dev. 3.3 (July 1959), 210–229. issn: 0018-8646. doi: 10.1147/rd.33.0210. url:
https://doi.org/10.1147/rd.33.0210.
9/21
AlphaGo
I AlphaGo is a system that combines:
I Imitation learning (behavioral cloning)
I Reinforcement learning (self-play)
I Planning (look-ahead search with MCTS)
I Massive computational power (Google’s data center)
I AlphaGo beat Lee Sedol (WC in Go) in 2016
I AlphaGo assumes access to a simulation model
(st, at) → st+1 that can be used for look-ahead search
I This assumption will be relaxed in MuZero later...
I Key Idea: Guided & truncated look-ahead search using
neural network predictions.
Capture
9/21
AlphaGo
I AlphaGo is a system that combines:
I Imitation learning (behavioral cloning)
I Reinforcement learning (self-play)
I Planning (look-ahead search with MCTS)
I Massive computational power (Google’s data center)
I AlphaGo beat Lee Sedol (WC in Go) in 2016
I AlphaGo assumes access to a simulation model
(st, at) → st+1 that can be used for look-ahead search
I This assumption will be relaxed in MuZero later...
I Key Idea: Guided & truncated look-ahead search using
neural network predictions.
Capture
10/21
Game Trees
I How do you program a computer to play a board game?
I Simplest approach:
I (1) Program a game tree; (2) Assume opponent think like you;
(3) Look-ahead and evaluate each move
I Requires Knowledge of game rules and evaluation
function
Ply 1
Ply 2
Ply 3
Depth = 3
Branching factor = 3
11/21
Search + Go =
12/21
Some Numbers
I Atoms in the universe
I ≈ 1080
I States
I Go: 10170
, Chess: 1047
I Game tree complexity
I Go: 10360
, Chess: 10123
I Average branching factor
I Go: 250, Chess: 35
I Board size (positions)
I Go: 361, Chess: 64
2 4 6 8
1 · 109
2 · 109
3 · 109
250depth
states
depth
12/21
AlphaGo Training Pipeline (1/2)
C
O
N
V
C
O
N
V
C
O
N
V
Supervised Rollout Policy Network
pπ (a|s)
Classification
minpπ
L(predicted move, expert move)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
Supervised Policy Network
pσ (a|s)
Classification
minpσ L(predicted move, expert move)
Human Expert Moves D1
12/21
AlphaGo Training Pipeline (1/2): Imitation Learning
Expert Demonstrations Supervised Learning
hState, Actioni pairs
12/21
AlphaGo Training Pipeline (2/2)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
Reinforcement Learning Policy Network
pρ (a|s)
Initialize with pσ weights
PolicyGradient
J(pρ) = Epρ
[
P∞
t=0 rt]
ρ ← ρ + α∇ρJ(pρ)
Self Play
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
Supervised Value Network
vθ(s0
)
Classification
minvθ
L(predicted outcome, actual outcome)
Self Play Dataset D2
13/21
Guided Search Search Using the Policy Network
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
PolicyNetwork
pσ/ρ (a|s)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
PolicyNetwork
pσ/ρ (a|s)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
PolicyNetwork
pσ/ρ (a|s)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
PolicyNetwork
pσ/ρ (a|s)
14/21
Depth-Limited Search Using the Value Network
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
15/21
AlphaGo Prediction Pipeline
Input
Position
Game State s
15/21
AlphaGo Prediction Pipeline
ML
predictions
Input
Position
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
PolicyNetwork
pσ/ρ (a|s)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
Game State s
15/21
AlphaGo Prediction Pipeline
Artifical
Intuition
By NNs
ML
predictions
Input
Position
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
PolicyNetwork
pσ/ρ (a|s)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
Game State s
HighValueAction
ActionDistribution pσ/ρ (a|s) ValueEstimates vθ(s0)
15/21
AlphaGo Prediction Pipeline
Guided-
Look-ahead
Search
(Self-play)
Artifical
Intuition
By NNs
ML
predictions
Input
Position
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
PolicyNetwork
pσ/ρ (a|s)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
Game State s
HighValueAction
ActionDistribution pσ/ρ (a|s) ValueEstimates vθ(s0)
Expansion
One or more nodes in
the search tree are created.
Selection
The selection function is
applied recursively
until a leaf node is reached.
Simulation
terminal state
rollout game
using model
of environment M
and policy π
Backpropagation
∆
∆
∆
∆
The result of the rollout
is backpropagated in the tree
15/21
AlphaGo Prediction Pipeline
Selected
Move
Guided-
Look-ahead
Search
(Self-play)
Artifical
Intuition
By NNs
ML
predictions
Input
Position
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
PolicyNetwork
pσ/ρ (a|s)
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
C
O
N
V
ValueNetwork
vθ(s0
)
Game State s
SelectedAction
HighValueAction
ActionDistribution pσ/ρ (a|s) ValueEstimates vθ(s0)
Expansion
One or more nodes in
the search tree are created.
Selection
The selection function is
applied recursively
until a leaf node is reached.
Simulation
terminal state
rollout game
using model
of environment M
and policy π
Backpropagation
∆
∆
∆
∆
The result of the rollout
is backpropagated in the tree
16/21
AlphaZero
I AlphaGo AlphaZero is a system that combines:
I Imitation learning (behavioral cloning)
I Reinforcement learning (self-play)
I Planning (look-ahead search with MCTS)
I Massive computational power (Google’s data center)
I AlphaZero works on Chess, Go, Shogi
I AlphaGo AlphaZero assumes access to a simulation model
(st, at) → st+1 that can be used for look-ahead search
I This assumption will be relaxed in MuZero later...
I Key Idea: Guided & truncated look-ahead search using
neural network predictions.
16/21
AlphaZero
I AlphaGo AlphaZero is a system that combines:
I Imitation learning (behavioral cloning)
I Reinforcement learning (self-play)
I Planning (look-ahead search with MCTS)
I Massive computational power (Google’s data center)
I AlphaZero works on Chess, Go, Shogi
I AlphaGo AlphaZero assumes access to a simulation model
(st, at) → st+1 that can be used for look-ahead search
I This assumption will be relaxed in MuZero later...
I Key Idea: Guided & truncated look-ahead search using
neural network predictions.
16/21
AlphaZero Self-Play Training Algorithm
s1
16/21
AlphaZero Self-Play Training Algorithm
s1
π1
16/21
AlphaZero Self-Play Training Algorithm
s1 s2
a1 ∼ π1
π1
16/21
AlphaZero Self-Play Training Algorithm
s1 s2
a1 ∼ π1
π1 π2
16/21
AlphaZero Self-Play Training Algorithm
s1 s2
a1 ∼ π1 . . .
at ∼ πt
π1 π2 z
16/21
AlphaZero Self-Play Training Algorithm
s1 s2
a1 ∼ π1 . . .
at ∼ πt
π1 π2 z
Self Play Training Data
fθ(st) = (pt, vt) θ0 = θ − α∇θL((pt, vt), (πt, z))
16/21
AlphaZero Self-Play Training Algorithm
s1 s2
a1 ∼ π1 . . .
at ∼ πt
π1 π2 z
Self Play Training Data
fθ(st) = (pt, vt) θ0 = θ − α∇θL((pt, vt), (πt, z))
L(fθ(st), (πt, z)) = (z − vt)2
| {z }
MSE
− πT
t log pt + c||θ||2
| {z }
Cross-entropy loss
17/21
From Specialized to General
Generality
Performance
AlphaGo
AlphaGo Zero
AlphaZero MuZero
18/21
The MuZero Algorithm
I AlphaGo, AlphaZero assume access to a simulation model
I MuZero does not assume access to a simulation model
I MuZero is a model-based RL algorithm that learns a model
I MuZero differs from traditinal model-based RL algorithms by:
1. The algorithm is based on function approximation
2. The algorithm learns the model implicitly
3. The algorithm uses look-ahead search in a novel way
4. Specialized neural architecture
model experience
value/policy
direct
RL
acting
model learning
planning
18/21
The MuZero Algorithm: Neural Network
Dynamics Function
rk
, sk
= gθ(sk−1
, ak
)
weight layer
weight layer
relu
x
relu
F(x)
F(x) + x
x
identity
Prediction Function
pk
, vk
= fθ(sk
)
v(s) ≈ P [win|s]
P [a|s]
P [an|s]
P [a1|s] . . .
fθ = (p, v)
ak
sk
s0
Initial State
rk pk
vk
Hidden State
Embedding Space
Recurrent Process
Shogi Atari Go Chess
Representation Function
s0
= hθ(o1, . . . , ot)
weight layer
weight layer
relu
x
relu
F(x)
F(x) + x
x
identity
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
18/21
The MuZero Algorithm: Training
Loss: ltθ =
PK
k=0 lr(ut+k, rtk
t
) + lv(zt+k, vk
t ) + lp(πt+k, pk
t ) + cθt
Lookahead search using Model of Environment
s0 s1
sK
gθ gθ
p0, v0 ≈ π0, z p1, v1 ≈ π1, z pK , vK ≈ πK , z
r1
rK
fθ fθ fθ
at+1
πt+1
ut+k
. . .
at+k
πt+k
ut+k
z
Sample Trajectory From Environment
18/21
The MuZero Algorithm: Planning
Game State
Sequence
Initial
Hidden State
Look-Ahead
Search
with MCTS,
dynamics function,
and prediction network
Representation Function s0 = hθ(01, . . . , ot)
hθ
s0
s1
s2
s3
gθ
gθ
gθ
a1
a2
a3
p2
, v2
← fθ
p1
, v1
← fθ
p0
, v0
← fθ
p3
, v3
← fθ
Shogi Atari Go Chess
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
歩
歩
歩
歩
歩
歩
歩
歩
歩
歩
角
角
角
香
香
桂
桂
銀
銀
金
金
玉
19/21
Limitations of MuZero and Drawbacks of the Paper
1. Sample efficiency:
I MuZero reduces need for prior knowledge by learning a model
I However, MuZero is not sample efficient
2. Cannot learn stochastic models:
I This is left for future work
I Many practical models are stochastic
s0
R1 = +5
R2 = +1
R3 = −3
R = 1
n
Pn
i=1 Ri

∇θJ(θ) = Eπθ
[∇θ log πθ(s, a)R]
x
πθ
θ ← θ + α 
∇θJ(θ)
Policy-Based
Q∗
(s, a) = E

rt+1 + γ max
a0
Q∗
(st+1, a0
)

MuZero - ML + Security Reading Group

  • 1.
    1/21 MuZero Mastering Atari, Go,Chess and Shogi by Planning with a Learned Model NSE ML+Security Reading Group Kim Hammar kimham@kth.se Division of Network and Systems Engineering KTH Royal Institute of Technology April 23, 2021
  • 2.
    2/21 The Context andKey Points of the Paper I MuZero is a model-based RL Algorithm I Target domain: Games (Atari, Go, Chess..) I A function-approximation approach to model-learning I Extension to the Alpha-Series: AlphaGo, AlphaZero, ... MuZero Agent Observations rt+1 Board features ∈ RK×19×19 Reward ∈ [−1, 1] at+1
  • 3.
    3/21 The Context andKey Points of the Paper Deep-Q-Network Playing Atari Nature, 14k citations 2015 AlphaGo Nature, 10k citations 2016 AlphaGo Zero Nature, 5.2k citations 2017 Alpha Zero Science, 1.3k citations 2018 Alpha Star Nature 2019, 800 citations MuZero Nature 2020, 300 citations
  • 4.
    4/21 Outline I Background I WhyGames I The Alpha Series I AlphaGo I AlphaGo Zero I The MuZero Algorithm I Limitations I Limitations of MuZero I Applications to Security? I Conclusions
  • 5.
    5/21 Background: Why Games b0 x0,1 x0,2 x0,3 b1 x1,1 x1,2 x1,3 ŷ Agent Environment Action a t rt st st+1 rt+1 C O N V C O N V C O N V C O N V C O N V Ply1 Ply 2 Ply 3 Depth = 3 Branching factor = 3 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 VA LV E R AI & Machine Learning Games Why Combine the two?
  • 6.
    5/21 Background: Why Games b0 x0,1 x0,2 x0,3 b1 x1,1 x1,2 x1,3 ŷ Agent Environment Action a t rt st st+1 rt+1 C O N V C O N V C O N V C O N V C O N V Ply1 Ply 2 Ply 3 Depth = 3 Branching factor = 3 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 VA LV E R AI & Machine Learning Games Why Combine the two? I AI & Games have a long history (Turing ’50& Minsky 60’) I Simple to evaluate, reproducible, controllable, quick feedback loop I Common benchmark for the research community
  • 7.
    6/21 Background: 1997 DeepBlue1 vsKasparov 1 Murray Campbell, A. Joseph Hoane, and Feng-hsiung Hsu. “Deep Blue”. In: Artif. Intell. 134.1–2 (Jan. 2002), 57–83. issn: 0004-3702. doi: 10.1016/S0004-3702(01)00129-1. url: https://doi.org/10.1016/S0004-3702(01)00129-1.
  • 8.
    7/21 Background: 1992 Tesauro’sTD-Gammon2 2 Gerald Tesauro. “TD-Gammon, a Self-Teaching Backgammon Program, Achieves Master-Level Play”. In: Neural Comput. 6.2 (Mar. 1994), 215–219. issn: 0899-7667. doi: 10.1162/neco.1994.6.2.215. url: https://doi.org/10.1162/neco.1994.6.2.215.
  • 9.
    8/21 Background: 1959 ArthurSamuel’s Checkers Player3 3 A. L. Samuel. “Some Studies in Machine Learning Using the Game of Checkers”. In: IBM J. Res. Dev. 3.3 (July 1959), 210–229. issn: 0018-8646. doi: 10.1147/rd.33.0210. url: https://doi.org/10.1147/rd.33.0210, A. L. Samuel. “Some Studies in Machine Learning Using the Game of Checkers”. In: IBM J. Res. Dev. 3.3 (July 1959), 210–229. issn: 0018-8646. doi: 10.1147/rd.33.0210. url: https://doi.org/10.1147/rd.33.0210.
  • 10.
    9/21 AlphaGo I AlphaGo isa system that combines: I Imitation learning (behavioral cloning) I Reinforcement learning (self-play) I Planning (look-ahead search with MCTS) I Massive computational power (Google’s data center) I AlphaGo beat Lee Sedol (WC in Go) in 2016 I AlphaGo assumes access to a simulation model (st, at) → st+1 that can be used for look-ahead search I This assumption will be relaxed in MuZero later... I Key Idea: Guided & truncated look-ahead search using neural network predictions. Capture
  • 11.
    9/21 AlphaGo I AlphaGo isa system that combines: I Imitation learning (behavioral cloning) I Reinforcement learning (self-play) I Planning (look-ahead search with MCTS) I Massive computational power (Google’s data center) I AlphaGo beat Lee Sedol (WC in Go) in 2016 I AlphaGo assumes access to a simulation model (st, at) → st+1 that can be used for look-ahead search I This assumption will be relaxed in MuZero later... I Key Idea: Guided & truncated look-ahead search using neural network predictions. Capture
  • 12.
    10/21 Game Trees I Howdo you program a computer to play a board game? I Simplest approach: I (1) Program a game tree; (2) Assume opponent think like you; (3) Look-ahead and evaluate each move I Requires Knowledge of game rules and evaluation function Ply 1 Ply 2 Ply 3 Depth = 3 Branching factor = 3
  • 13.
  • 14.
    12/21 Some Numbers I Atomsin the universe I ≈ 1080 I States I Go: 10170 , Chess: 1047 I Game tree complexity I Go: 10360 , Chess: 10123 I Average branching factor I Go: 250, Chess: 35 I Board size (positions) I Go: 361, Chess: 64 2 4 6 8 1 · 109 2 · 109 3 · 109 250depth states depth
  • 15.
    12/21 AlphaGo Training Pipeline(1/2) C O N V C O N V C O N V Supervised Rollout Policy Network pπ (a|s) Classification minpπ L(predicted move, expert move) C O N V C O N V C O N V C O N V C O N V Supervised Policy Network pσ (a|s) Classification minpσ L(predicted move, expert move) Human Expert Moves D1
  • 16.
    12/21 AlphaGo Training Pipeline(1/2): Imitation Learning Expert Demonstrations Supervised Learning hState, Actioni pairs
  • 17.
    12/21 AlphaGo Training Pipeline(2/2) C O N V C O N V C O N V C O N V C O N V Reinforcement Learning Policy Network pρ (a|s) Initialize with pσ weights PolicyGradient J(pρ) = Epρ [ P∞ t=0 rt] ρ ← ρ + α∇ρJ(pρ) Self Play C O N V C O N V C O N V C O N V C O N V Supervised Value Network vθ(s0 ) Classification minvθ L(predicted outcome, actual outcome) Self Play Dataset D2
  • 18.
    13/21 Guided Search SearchUsing the Policy Network C O N V C O N V C O N V C O N V C O N V PolicyNetwork pσ/ρ (a|s) C O N V C O N V C O N V C O N V C O N V PolicyNetwork pσ/ρ (a|s) C O N V C O N V C O N V C O N V C O N V PolicyNetwork pσ/ρ (a|s) C O N V C O N V C O N V C O N V C O N V PolicyNetwork pσ/ρ (a|s)
  • 19.
    14/21 Depth-Limited Search Usingthe Value Network C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) C O N V C O N V C O N V C O N V C O N V C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 )
  • 20.
  • 21.
  • 22.
    15/21 AlphaGo Prediction Pipeline Artifical Intuition ByNNs ML predictions Input Position C O N V C O N V C O N V C O N V C O N V PolicyNetwork pσ/ρ (a|s) C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) Game State s HighValueAction ActionDistribution pσ/ρ (a|s) ValueEstimates vθ(s0)
  • 23.
    15/21 AlphaGo Prediction Pipeline Guided- Look-ahead Search (Self-play) Artifical Intuition ByNNs ML predictions Input Position C O N V C O N V C O N V C O N V C O N V PolicyNetwork pσ/ρ (a|s) C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) Game State s HighValueAction ActionDistribution pσ/ρ (a|s) ValueEstimates vθ(s0) Expansion One or more nodes in the search tree are created. Selection The selection function is applied recursively until a leaf node is reached. Simulation terminal state rollout game using model of environment M and policy π Backpropagation ∆ ∆ ∆ ∆ The result of the rollout is backpropagated in the tree
  • 24.
    15/21 AlphaGo Prediction Pipeline Selected Move Guided- Look-ahead Search (Self-play) Artifical Intuition ByNNs ML predictions Input Position C O N V C O N V C O N V C O N V C O N V PolicyNetwork pσ/ρ (a|s) C O N V C O N V C O N V C O N V C O N V ValueNetwork vθ(s0 ) Game State s SelectedAction HighValueAction ActionDistribution pσ/ρ (a|s) ValueEstimates vθ(s0) Expansion One or more nodes in the search tree are created. Selection The selection function is applied recursively until a leaf node is reached. Simulation terminal state rollout game using model of environment M and policy π Backpropagation ∆ ∆ ∆ ∆ The result of the rollout is backpropagated in the tree
  • 25.
    16/21 AlphaZero I AlphaGo AlphaZerois a system that combines: I Imitation learning (behavioral cloning) I Reinforcement learning (self-play) I Planning (look-ahead search with MCTS) I Massive computational power (Google’s data center) I AlphaZero works on Chess, Go, Shogi I AlphaGo AlphaZero assumes access to a simulation model (st, at) → st+1 that can be used for look-ahead search I This assumption will be relaxed in MuZero later... I Key Idea: Guided & truncated look-ahead search using neural network predictions.
  • 26.
    16/21 AlphaZero I AlphaGo AlphaZerois a system that combines: I Imitation learning (behavioral cloning) I Reinforcement learning (self-play) I Planning (look-ahead search with MCTS) I Massive computational power (Google’s data center) I AlphaZero works on Chess, Go, Shogi I AlphaGo AlphaZero assumes access to a simulation model (st, at) → st+1 that can be used for look-ahead search I This assumption will be relaxed in MuZero later... I Key Idea: Guided & truncated look-ahead search using neural network predictions.
  • 27.
  • 28.
  • 29.
    16/21 AlphaZero Self-Play TrainingAlgorithm s1 s2 a1 ∼ π1 π1
  • 30.
    16/21 AlphaZero Self-Play TrainingAlgorithm s1 s2 a1 ∼ π1 π1 π2
  • 31.
    16/21 AlphaZero Self-Play TrainingAlgorithm s1 s2 a1 ∼ π1 . . . at ∼ πt π1 π2 z
  • 32.
    16/21 AlphaZero Self-Play TrainingAlgorithm s1 s2 a1 ∼ π1 . . . at ∼ πt π1 π2 z Self Play Training Data fθ(st) = (pt, vt) θ0 = θ − α∇θL((pt, vt), (πt, z))
  • 33.
    16/21 AlphaZero Self-Play TrainingAlgorithm s1 s2 a1 ∼ π1 . . . at ∼ πt π1 π2 z Self Play Training Data fθ(st) = (pt, vt) θ0 = θ − α∇θL((pt, vt), (πt, z)) L(fθ(st), (πt, z)) = (z − vt)2 | {z } MSE − πT t log pt + c||θ||2 | {z } Cross-entropy loss
  • 34.
    17/21 From Specialized toGeneral Generality Performance AlphaGo AlphaGo Zero AlphaZero MuZero
  • 35.
    18/21 The MuZero Algorithm IAlphaGo, AlphaZero assume access to a simulation model I MuZero does not assume access to a simulation model I MuZero is a model-based RL algorithm that learns a model I MuZero differs from traditinal model-based RL algorithms by: 1. The algorithm is based on function approximation 2. The algorithm learns the model implicitly 3. The algorithm uses look-ahead search in a novel way 4. Specialized neural architecture model experience value/policy direct RL acting model learning planning
  • 36.
    18/21 The MuZero Algorithm:Neural Network Dynamics Function rk , sk = gθ(sk−1 , ak ) weight layer weight layer relu x relu F(x) F(x) + x x identity Prediction Function pk , vk = fθ(sk ) v(s) ≈ P [win|s] P [a|s] P [an|s] P [a1|s] . . . fθ = (p, v) ak sk s0 Initial State rk pk vk Hidden State Embedding Space Recurrent Process Shogi Atari Go Chess Representation Function s0 = hθ(o1, . . . , ot) weight layer weight layer relu x relu F(x) F(x) + x x identity 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉
  • 37.
    18/21 The MuZero Algorithm:Training Loss: ltθ = PK k=0 lr(ut+k, rtk t ) + lv(zt+k, vk t ) + lp(πt+k, pk t ) + cθt Lookahead search using Model of Environment s0 s1 sK gθ gθ p0, v0 ≈ π0, z p1, v1 ≈ π1, z pK , vK ≈ πK , z r1 rK fθ fθ fθ at+1 πt+1 ut+k . . . at+k πt+k ut+k z Sample Trajectory From Environment
  • 38.
    18/21 The MuZero Algorithm:Planning Game State Sequence Initial Hidden State Look-Ahead Search with MCTS, dynamics function, and prediction network Representation Function s0 = hθ(01, . . . , ot) hθ s0 s1 s2 s3 gθ gθ gθ a1 a2 a3 p2 , v2 ← fθ p1 , v1 ← fθ p0 , v0 ← fθ p3 , v3 ← fθ Shogi Atari Go Chess 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉 歩 歩 歩 歩 歩 歩 歩 歩 歩 歩 角 角 角 香 香 桂 桂 銀 銀 金 金 玉
  • 39.
    19/21 Limitations of MuZeroand Drawbacks of the Paper 1. Sample efficiency: I MuZero reduces need for prior knowledge by learning a model I However, MuZero is not sample efficient 2. Cannot learn stochastic models: I This is left for future work I Many practical models are stochastic s0 R1 = +5 R2 = +1 R3 = −3 R = 1 n Pn i=1 Ri ∇θJ(θ) = Eπθ [∇θ log πθ(s, a)R] x πθ θ ← θ + α ∇θJ(θ) Policy-Based Q∗ (s, a) = E rt+1 + γ max a0 Q∗ (st+1, a0 )
  • 43.
    s, a = X s0 Pa ss0 Ra ss0 +γ max a0 Q∗ (s0 , a0 ) s0 V (s) Q(s, a) x Value-Based high low 1 − α, Rsearch 1, Rwait α, Rsearch 1, Rwait 1 − β, −3 1.0 recharge search wait search wait β, Rsearch M = hS, A, Pa ss0 , Ra ss0 i x Model-Based Planning Actor-Critic
  • 44.
    20/21 Applications to Security? IMany infrastructures cannot be described by simple equations I Alternative approach: estimate/learn a model I Benefit of model-based RL: more sample efficient (generally) I Can we use MuZero to Learn the Model? I In principle, yes. I In practice, no. I Muzero is likely to be too sample inefficient for realistic infrastructures
  • 45.
    21/21 Conclusions I MuZero isa new model-based RL algorithm I MuZero generalizes AlphaZero to not require prior knowledge about the environment dynamics I MuZero uses implicit learning of environment dynamics I MuZero is a new state of the art on several games I Can we use MuZero for other domains than games? I MuZero reduces need for prior knowledge but does not reduce the number of samples required I MuZero has some interesting ideas, but needs to be developed further (IMO)