M ASTERING A TARI WITH D ISCRETE W ORLD M ODELS
Google Research
A BSTRACT
Intelligent agents need to generalize from past experience to achieve goals in complex environments.
World models facilitate such generalization and allow learning behaviors from imagined outcomes to increase sample-efﬁciency.
While learning world models from image inputs has recently become feasible for some tasks, modeling Atari games accurately enough to derive successful behaviors has remained an open challenge for many years.
We introduce DreamerV2, a reinforcement learning agent that learns behaviors purely from predictions in the compact latent space of a powerful world model.
The world model uses discrete representations and is trained separately from the policy.
DreamerV2 constitutes the ﬁrst agent that achieves human-level performance on the Atari benchmark oftasks by learning behaviors inside a separately trained world model.
With the same computational budget and wall-clock time, Dreamer V2 reaches 200M frames and surpasses the ﬁnal performance of the top single-GPU agents IQN and Rainbow.
DreamerV2 is also applicable to tasks with continuous actions, where it learns an accurate world model of a complex humanoid robot and solves stand-up and walking from only pixel inputs.
I NTRODUCTION
D r e a m e r V R a i n b o w I Q N D Q N
D r e a m e r V S i m P L e [Figure] DreamerV2 is the ﬁrst agent that learns purely within a world model to achieve human-level Atari performance, demonstrating the high accuracy of its learned world model.
DreamerV2 further outperforms the top single-GPU agents Rainbow and IQN, whose scores are provided by Dopamine (Castro et al., 2018).
According to its authors, SimPLe (Kaiser et al., 2019) was only evaluated on an easier subset of 36 games and trained for fewer steps and additional training does not further increase its performance.
To successfully operate in unknown environments, reinforcement learning agents need to learn about their environments over time.
World models are an explicit way to represent an agent’s knowledge about its environment.
Compared to model-free reinforcement learning that learns through trial and error, world models facilitate generalization and can predict the outcomes of potential actions to enable planning (Sutton, 1991).
Capturing general aspects of the environment, world models have been shown to be effective for transfer to novel tasks (Byravan et al., 2019), directed exploration (Sekar et al., 2020), and generalization from ofﬂine datasets (Yu et al., 2020).
When the inputs are high-dimensional images, latent dynamics models predict ahead in an abstract latent space (Watter et al., 2015;
Ha and Schmidhuber, 2018; Hafner et al., 2018; Zhang et al., 2019).
Predicting compact representations instead of images has been hypothesized to reduce accumulating errors and their small memory footprint enables thousands of parallel predictions on a single GPU (Hafner et al., 2018; 2019).
Leveraging this approach, the recent Dreamer agent (Hafner et al., 2019) has solved a wide range of continuous control tasks from image inputs.
Despite their intriguing properties, world models have so far not been accurate enough to compete with the stateof-the-art model-free algorithms on the most competitive benchmarks.
The well-established Atari benchmark (Bellemare et al., 2013) historically required model-free algorithms to achieve human-level performance, such as DQN (Mnih et al., 2015), A3C (Mnih et al., 2016), or Rainbow (Hessel et al., 2018).
Several attempts at learning accurate world models of Atari games have been made, without achieving competitive performance (Oh et al., 2015; Chiappa et al., 2017; Kaiser et al., 2019).
On the other hand, the recently proposed MuZero agent (Schrittwieser et al., 2019) shows that planning can achieve impressive performance on board games and deterministic Atari games given extensive engineering effort and a vast computational budget.
However, its implementation is not available to the public and it would require over 2 months of computation to train even one agent on a GPU, rendering it impractical for most research groups.
In this paper, we introduce DreamerV2, the ﬁrst reinforcement learning agent that achieves humanlevel performance on the Atari benchmark by learning behaviors purely within a separately trained world model, as shown in Figure 1.
Learning successful behaviors purely within the world model demonstrates that the world model learns to accurately represent the environment.
To achieve this, we apply small modiﬁcations to the Dreamer agent (Hafner et al., 2019), such as using discrete latents and balancing terms within the KL loss.
Using a single GPU and a single environment instance,
DreamerV2 outperforms top single-GPU Atari agents Rainbow (Hessel et al., 2018) and IQN (Dabney et al., 2018), which rest upon years of model-free reinforcement learning research (Van Hasselt et al., 2015; Schaul et al., 2015; Wang et al., 2016; Bellemare et al., 2017; Fortunato et al., 2017).
Moreover, aspects of these algorithms are complementary to our world model and could be integrated into the
Dreamer framework in the future.
To rigorously compare the algorithms, we report scores normalized by both a human gamer (Mnih et al., 2015) and the human world record (Toromanoff et al., 2019) and make a suggestion for reporting scores going forward.
D REAMER V
We present DreamerV2, an evolution of the Dreamer agent (Hafner et al., 2019).
We refer to the original Dreamer agent as DreamerV1 throughout this paper.
This section describes the complete
DreamerV2 algorithm, consisting of the three typical components of a model-based agent (Sutton, 1991).
We learn the world model from a dataset of past experience, learn an actor and critic from imagined sequences of compact model states, and execute the actor in the environment to grow the experience dataset.
In Appendix C, we include a list of changes that we applied to DreamerV1 and which of them we found to increase empirical performance.
2. W ORLD M ODEL L EARNING
World models summarize an agent’s experience into a predictive model that can be used in place of the environment to learn behaviors.
When inputs are high-dimensional images, it is beneﬁcial to learn compact state representations of the inputs to predict ahead in this learned latent space (Watter et al., 2015; Karl et al., 2016;
Ha and Schmidhuber, 2018).
These models are called latent dynamics models.
Predicting ahead in latent space not only facilitates long-term predictions, it also allows to efﬁciently predict thousands of compact state sequences in parallel in a single batch, without having to generate images.
DreamerV2 builds upon the world model that was introduced by PlaNet (Hafner et al., 2018) and used in DreamerV1, by replacing its Gaussian latents with categorical variables.
Experience dataset The world model is trained from the agent’s growing dataset of past experience that contains sequences of images x 1: T , actions a 1: T , rewards r 1: T , and discount factors γ 1: T .
The discount factors equal a ﬁxed hyper parameter γ = 0 .
999 for time steps within an episode and are set to zero for terminal time steps.
For training, we use batches of B = 50 sequences of ﬁxed length
L = 50 that are sampled randomly within the stored episodes.
To observe enough episode ends during training, we sample the start index of each training sequence uniformly within the episode and then clip it to not exceed the episode length minus the training sequence length.
Model components The world model consists of an image encoder, a Recurrent State-Space Model (RSSM; Hafner et al., 2018) to learn the dynamics, and predictors for the image, reward, and discount factor.
The world model is summarized in Figure 2.
The RSSM uses a sequence of deterministic recurrent states h t , from which it computes two distributions over stochastic states at each step.
The posterior state z t incorporates information about the current image x t , while the prior state ˆ z t aims to predict the posterior without access to the current image.
The concatenation of deterministic and
[Figure]
z
[Figure] 32 classes each 32 c a t e g o r i c a l s x [Figure]
The RSSM uses a sequence of deterministic recurrent states h t .
At each step, it computes a posterior stochastic state z t that incorporates information about the current image x t , as well as a prior stochastic state ˆ z t that tries to predict the posterior without access to the current image.
Unlike in
PlaNet and DreamerV1, the stochastic state of DreamerV2 is a vector of multiple categorical variables.
The learned prior is used for imagination, as shown in Figure 3.
The KL loss both trains the prior and regularizes how much information the posterior incorporates from the image.
The regularization increases robustness to novel inputs.
It also encourages reusing existing information from past steps to predict rewards and reconstruct images, thus learning long-term dependencies.
stochastic states forms the compact model state.
From the posterior model state, we reconstruct the current image x t and predict the reward r t and discount factor γ t .
The model components are:
[Equation]
Representation
[Equation]
Transition predictor
[Equation]
predictor
[Equation]
[Equation]
All components are implemented as neural networks and φ describes their combined parameter vector.
The transition predictor guesses the next model state only from the current model state and the action but without using the next image, so that we can later learn behaviors by predicting sequences of model states without having to observe or generate images.
The discount predictor lets us estimate the probability of an episode ending when learning behaviors from model predictions.
Neural networks The representation model is implemented as a Convolutional Neural Network (CNN; LeCun et al., 1989) followed by a Multi-Layer Perceptron (MLP) that receives the image embedding and the deterministic recurrent state.
The RSSM uses a Gated Recurrent Unit (GRU; Cho et al., 2014) to compute the deterministic recurrent states.
The model state is the concatenation of deterministic GRU state and a sample of the stochastic state.
The image predictor is a transposed
CNN and the transition, reward, and discount predictors are MLPs.
We down-scale the 84 ×grayscale images to 64 × 64 pixels so that we can apply the convolutional architecture of DreamerV1.
Algorithm 1: Straight-Through Gradients with Automatic Differentiation sample = one_hot(draw( logits ))
# sample has no gradient probs = softmax( logits ) # want gradient of this sample
= sample + probs - stop_grad( probs ) # has gradient of probs
We use the ELU activation function for all components of the model (Clevert et al., 2015).
The world model uses a total of 20M trainable parameters.
Distributions
The image predictor outputs the mean of a diagonal Gaussian likelihood with unit variance, the reward predictor outputs a univariate Gaussian with unit variance, and the discount predictor outputs a Bernoulli likelihood.
In prior work, the latent variable in the model state was a diagonal Gaussian that used reparameterization gradients during backpropagation (Kingma and
Welling, 2013; Rezende et al., 2014).
In DreamerV2, we instead use a vector of several categorical variables and optimize them using straight-through gradients (Bengio et al., 2013), which are easy to implement using automatic differentiation as shown in Algorithm 1.
We discuss possible beneﬁts of categorical over Gaussian latents in the experiments section.
Loss function All components of the world model are optimized jointly.
The distributions produced by the image predictor, reward predictor, discount predictor, and transition predictor are trained to maximize the log-likelihood of their corresponding targets.
The representation model is trained to produce model states that facilitates these prediction tasks, through the expectation below.
Moreover, it is regularized to produce model states with high entropy, such that the model becomes robust to many different model states during training.
The loss function for learning the world model is:
[Equation]
loss [Equation] We jointly minimize the loss function with respect to the vector φ that contains all parameters of the world model using the Adam optimizer (Kingma and Ba, 2014).
We scale the KL loss by β = 0 . 1 for
Atari and by β = 1 . 0 for continuous control (Higgins et al., 2016).
KL balancing The world model loss function in Equation 2 is the ELBO or variational free energy of a hidden Markov model that is conditioned on the action sequence.
The world model can thus be interpreted as a sequential VAE, where the representation model is the approximate posterior and the transition predictor is the temporal prior.
In the ELBO objective, the KL loss serves two purposes: it trains the prior toward the representations, and it regularizes the representations toward the prior.
However, learning the transition function is difﬁcult and we want to avoid regularizing the representations toward a poorly trained prior. To solve this problem, we minimize the KL loss faster with respect to the prior than the representations by using different learning rates, α = 0 .for the prior and 1 − α for the approximate posterior.
We implement this technique as shown in Algorithm 2 and refer to it as KL balancing.
KL balancing encourages learning an accurate prior over increasing posterior entropy, so that the prior better approximates the aggregate posterior.
KL balancing is different from and orthogonal to beta-VAEs (Higgins et al., 2016).
2. B EHAVIOR L EARNING
DreamerV2 learns long-horizon behaviors purely within its world model using an actor and a critic.
The actor chooses actions for predicting imagined sequences of compact model states.
The critic accumulates the future predicted rewards to take into account rewards beyond the planning horizon.
Both the actor and critic operate on top of the learned model states and thus beneﬁt from the representations learned by the world model.
The world model is ﬁxed during behavior learning, so the actor and value gradients do not affect its representations.
Not predicting images during behavior learning lets us efﬁciently simulate 2500 latent trajectories in parallel on a single GPU.
Imagination MDP To learn behaviors within the latent space of the world model, we deﬁne the imagination MPD as follows.
The distribution of initial states ˆ z 0 in the imagination MDP is the distribution of compact model states encountered during world model training.
From there, the transition predictor p φ (ˆ z t | ˆ z t − 1 , ˆ a t − 1 ) outputs sequences ˆ z 1: H of compact model states up to the
Algorithm 2: KL Balancing with Automatic Differentiation [Equation] h [Figure]
z [Figure] z [Figure]
z [Figure] ^ xrrr 3 ^ ^ ^ vvv 3 aa 2 ^
^
^ ^ ^ hh 3 ^
^
a 3 ^ z 4 ^ r 4 ^ v 4 ^
h 4 ^ a 4 ^ imagination horizon H = 15 .
The mean of the reward predictor p φ (ˆ r t | ˆ z t ) is used as reward sequence ˆ r 1: H .
The discount predictor p φ (ˆ γ t | ˆ z t ) outputs the discount sequence ˆ γ 1: H that is used to down-weight rewards.
Moreover, we weigh the loss terms of the actor and critic by the cumulative predicted discount factors to softly account for the possibility of episode ends.
Model components To learn long-horizon behaviors in the imagination MDP, we leverage a stochastic actor that chooses actions and a deterministic critic.
The actor and critic are trained cooperatively, where the actor aims to output actions that lead to states that maximize the critic output, while the critic aims to accurately estimate the sum of future rewards achieved by the actor from each imagined state.
The actor and critic use the parameter vectors ψ and ξ , respectively:
[Equation]
In contrast to the actual environment, the latent state sequence is Markovian, so that there is no need for the actor and critic to condition on more than the current model state.
The actor and critic are both MLPs with ELU activations (Clevert et al., 2015) and use 1M trainable parameters each.
The actor outputs a categorical distribution over actions and the critic has a deterministic output.
The two components are trained from the same imagined trajectories but optimize separate loss functions.
Critic loss function The critic aims to predict the discounted sum of future rewards that the actor achieves in a given model state, known as the state value.
For this, we leverage temporal-difference learning, where the critic is trained toward a value target that is constructed from intermediate rewards and critic outputs for later states.
A common choice is the 1-step target that sums the current reward and the critic output for the following state.
However, the imagination MDP lets us generate on-policy trajectories of multiple steps, suggesting the use of n-step targets that incorporate reward information into the critic more quickly.
We follow DreamerV1 in using the more general λ -target (Sutton and
Barto, 2018; Schulman et al., 2015) that is deﬁned recursively as follows:
[Equation]
Intuitively, the λ -target is a weighted average of n-step returns for different horizons, where longer horizons are weighted exponentially less.
We set λ = 0 .
95 in practice, to focus more on long horizon targets than on short horizon targets.
Given a trajectory of model states, rewards, and discount factors, we train the critic to regress the λ -return using a squared loss:
[Equation]
We optimize the critic loss with respect to the critic parameters ξ using the Adam optimizer.
There is no loss term for the last time step because the target equals the critic at that step.
We stop the gradients around the targets, denoted by the sg( · ) function, as typical in the literature.
We stabilize value learning using a target network (Mnih et al., 2015), namely, we compute the targets using a copy of the critic that is updated every 100 gradient steps.
Actor loss function The actor aims to output actions that maximize the prediction of long-term future rewards made by the critic.
To incorporate intermediate rewards more directly, we train the actor to maximize the same λ -return that was computed for training the critic.
There are different gradient estimators for maximizing the targets with respect to the actor parameters.
DreamerV combines unbiased but high-variance Reinforce gradients with biased but low-variance straightthrough gradients.
Moreover, we regularize the entropy of the actor to encourage exploration where feasible while allowing the actor to choose precise actions when necessary.
Learning by Reinforce (Williams, 1992) maximizes the actor’s
probability of its own sampled actions weighted by the values of those actions.
The variance of this estimator can be reduced by subtracting the state value as baseline, which does not depend on the current action.
Intuitively, subtracting the baseline centers the weights and leads to faster learning.
The beneﬁt of Reinforce is that it produced unbiased gradients and the downside is that it can have high variance, even with baseline.
DreamerV1 relied entirely on reparameterization gradients (Kingma and Welling, 2013; Rezende et al., 2014) to train the actor directly by backpropagating value gradients through the sequence of sampled model states and actions.
DreamerV2 uses both discrete latents and discrete actions.
To backpropagate through the sampled actions and state sequences, we leverage straight-through gradients (Bengio et al., 2013).
This results in a biased gradient estimate with low variance.
The combined actor loss function is:
[Equation]
We optimize the actor loss with respect to the actor parameters ψ using the Adam optimizer.
We consider both Reinforce gradients and straight-through [-dynamics backpropagation η d = 0 . 1 → 0 . 
-]gradients, which backpropagate directly through the learned dynamics.
Intuitively, the low-variance but biased dynamics backpropagation could learn faster initially and the unbiased but high-variance could to converge to a better solution. For Atari, we ﬁnd Reinforce gradients to work substantially better and use ρ = 1 and η = 10 − 3 . For continuous control, we ﬁnd dynamics backpropagation to work substantially better and use ρ =and η = 10 − 4 .
Annealing these hyper parameters can improve performance slightly but to avoid the added complexity we report the scores without annealing.
E XPERIMENTS
We evaluate DreamerV2 on the well-established Atari benchmark with sticky actions, comparing to four strong model-free algorithms.
DreamerV2 outperforms the four model-free algorithms in all scenarios.
For an extensive comparison, we report four scores according to four aggregation protocols and give a recommendation for meaningfully aggregating scores across games going forward.
We also ablate the importance of discrete representations in the world model.
Our implementation of
DreamerV2 reaches 200M environment steps in under 10 days, while using only a single NVIDIA
V100 GPU and a single environment instance.
During the 200M environment steps, DreamerV learns its policy from 468B compact states imagined under the model, which is 10,000 × more
[Figure]
Clipped [Figure] Experimental setup We select the 55 games that prior works in the literature from different research labs tend to agree on (Mnih et al., 2016;
Brockman et al., 2016; Hessel et al., 2018; Castro et al., 2018; Badia et al., 2020) and recommend this set of games for evaluation going forward.
We follow the evaluation protocol of Machado et al.
(2018) with 200M environment steps, action repeat of 4, a time limit of 108,000 steps per episode that correspond to 30 minutes of game play, no access to life information, full action space, and sticky actions.
Because the world model integrates information over time, DreamerV2 does not use frame stacking.
The experiments use a single-task setup where a separate agent is trained for each game.
Moreover, each agent uses only a single environment instance.
We compare the algorithms based on both human gamer and human world record normalization (Toromanoff et al., 2019).
Model-free baselines We compare the learning curves and ﬁnal scores of DreamerV2 to four model-free algorithms, IQN (Dabney et al., 2018), Rainbow (Hessel et al., 2018), C51 (Bellemare et al., 2017), and DQN (Mnih et al., 2015).
We use the scores of these agents provided by the
Dopamine framework (Castro et al., 2018) that use sticky actions.
These may differ from the reported results in the papers that introduce these algorithms in the deterministic Atari setup.
The training time of Rainbow was reported at 10 days on a single GPU and using one environment instance.
3. A TARI P ERFORMANCE
The performance curves of DreamerV2 and four standard model-free algorithms are visualized in Figure 4.
The ﬁnal scores at 200M environment steps are shown in Table 1 and the scores on individual games are included in Table K1.
There are different approaches for aggregating the scores across the 55 games and we show that this choice can have a substantial impact on the relative performance between algorithms.
To extensively compare DreamerV2 to the model-free algorithms, we consider the following four aggregation approaches:
[Table]
Latent Variables
CategoricalGaussian 0.0 0.5 1.0 1.5 2.
KL Balancing
EnabledDisabled 0.0 0.5 1.0 1.5 2.
Image Gradients
EnabledDisabled 0.0 0.5 1.0 1.5 2.0 1e 0.
Reward Gradients
EnabledDisabled
• Gamer Median Atari scores are commonly normalized based on a random policy and a professional gamer, averaged over seeds and the median over tasks is reported (Mnih et al., 2015; 2016).
However, if almost half of the scores would be zero, the median would not be affected.
Thus, we argue that median scores are not reﬂective of the robustness of an algorithm and results in wasted computational resources for games that will not affect the score.
• Gamer Mean Compared to the task median, the task mean considers all tasks.
However, the gamer performed poorly on a small number of games, such as Crazy Climber, James Bond and Video Pinball.
This makes it easy for algorithms to achieve a high normalized score on these few games, which then dominate the task mean
so it is not informative of overall performance.
• Record Mean Instead of normalizing based on the professional gamer, Toromanoff et al.
(2019) suggest to normalize based on the registered human world record of each game.
This partially addresses the outlier problem but the mean is still dominated by games where the algorithms easily achieve superhuman performance.
• Clipped Record Mean To overcome these limitations, we recommend normalizing by the human world record and then clipping the scores to not exceed a value of 1, so that performance above the record does not further increase the score
The result is a robust measure of algorithm performance on the Atari suite that considers performance across all games
From Figure 4 and Table 1, we see that the different aggregation approaches let us examine agent performance from different angles.
Interestingly, Rainbow clearly outperforms IQN in the ﬁrst aggregation method but IQN clearly outperforms Rainbow in the remaining setups.
DreamerV outperforms the model-free agents in all four metrics, with the largest margin in record normalized mean performance.
Despite this, we recommend clipped record normalized mean as the most meaningful aggregation method, as it considers all tasks to a similar degree without being dominated by a small number of outlier scores.
In Table 1, we also include DreamerV2 with schedules that anneal the actor entropy loss scale and actor gradient mixing over the course of training, which further increases the gamer median score of DreamerV2.
Individual games The scores on individual Atari games at 200M environment steps are included in
Table K1, alongside the model-free algorithms and the baselines of random play, human gamer, and human world record.
We ﬁlled in reasonable values for the 2 out of 55 games that have no registered world record.
Figure E1 compares the score differences between DreamerV2 and each model-free algorithm for the individual games.
DreamerV2 achieves comparable or higher performance on most games except for Video Pinball.
We hypothesize that the reconstruction loss of the world model does not encourage learning a meaningful latent representation because the most important object in the game, the ball, occupies only a single pixel.
One the other hand, DreamerV2 achieves the strongest improvements over the model-free agents on the games James Bond, Up N Down, and Assault. [Table]
substantially contribute to the success of DreamerV2.
Moreover, the world model relies on image gradients to learn general representations that lead to successful behaviors, even if the representations are not speciﬁcally learned for predicting past rewards
3. A BLATION S TUDY
To understand which ingredients of DreamerV2 are responsible for its success, we conduct an extensive ablation study.
We compare equipping the world model with categorical latents, as in
DreamerV2, to Gaussian latents, as in DreamerV1.
Moreover, we study the importance of KL balancing.
Finally, we investigate the importance of gradients from image reconstruction and reward prediction for learning the model representations, by stopping one of the two gradient signals before entering the model states.
The results of the ablation study are summarized in Figure 5 and Table 2.
Refer to the appendix for the score curves of the individual tasks.
Categorical latents Categorical latent variables outperform than Gaussian latent variables ontasks, achieve lower performance on 8 tasks, and are tied on 5 tasks.
We deﬁne a tie as being within 5% of another.
While we do not know the reason why the categorical variables are beneﬁcial, we state several hypotheses that can be investigated in future work:
• A categorical prior can perfectly ﬁt the aggregate posterior, because a mixture of categoricals is again a categorical.
In contrast, a Gaussian prior cannot match a mixture of Gaussian posteriors, which could make it difﬁcult to predict multi-modal changes between one image and the next.
• The level of sparsity enforced by a vector of categorical latent variables could be beneﬁcial for generalization.
Flattening the sample from the 32 categorical with 32 classes each results in a sparse binary vector of length 1024 with 32 active bits.
• Despite common intuition, categorical variables may be easier to optimize than Gaussian variables, possibly because the straight-through gradient estimator ignores a term that would otherwise scale the gradient.
This could reduce exploding and vanishing gradients.
• Categorical variables could be a better inductive bias than unimodal continuous latent variables for modeling the non-smooth aspects of Atari games, such as when entering a new room, or when collected items or defeated enemies disappear from the image.
KL balancing KL balancing outperforms the standard KL regularizer on 44 tasks, achieves lower performance on 6 tasks, and is tied on 5 tasks.
Learning accurate prior dynamics of the world model is critical because it is used for imagining latent state trajectories using policy optimization.
By scaling up the prior cross entropy relative to the posterior entropy, the world model is encouraged to minimize the KL by improving its prior dynamics toward the more informed posteriors, as opposed to reducing the KL by increasing the posterior entropy.
KL balancing may also be beneﬁcial for probabilistic models with learned priors beyond world models.
Model gradients Stopping the image gradients increases performance on 3 tasks, decreases performance on 51 tasks, and is tied on 1 task.
The world model of DreamerV2 thus heavily relies on the learning signal provided by the high-dimensional images.
Stopping the reward gradients increases performance on 15 tasks, decreases performance on 22 tasks, and is tied on 18 tasks.
Figure H further shows that the difference in scores is small.
In contrast to MuZero, DreamerV2 thus learns general representations of the environment state from image information alone.
Stopping reward gradients improved performance on a number of tasks, suggesting that the representations that are not speciﬁc to previously experienced rewards may generalize better to unseen situations. [Table]
DreamerV2 and SimPLe learn complete models of the environment by leveraging the learning signal provided by the image inputs, while MuZero learns its model through value gradients that are speciﬁc to an individual task.
The Monte-Carlo tree search used by MuZero is effective but adds complexity and is challenging to parallelize.
This component is orthogonal to the world model proposed here.
Policy gradients Using only Reinforce gradients to optimize the policy increases performance on 18 tasks, decreases performance on 24 tasks, and is tied on 13 tasks.
This shows that DreamerV2 relies mostly on Reinforce gradients to learn the policy.
However, mixing Reinforce and straight-through gradients yields a substantial improvement on James Bond and Seaquest, leading to a higher gamer normalized task mean score.
Using only straight-through gradients to optimize the policy increases performance on 5 tasks, decreases performance on 44 tasks, and is tied on 6 tasks.
We conjecture that straight-through gradients alone are not well suited for policy optimization because of their bias.
R ELATED W ORK
Model-free Atari
The majority of agents applied to the Atari benchmark have been trained using model-free algorithms.
DQN (Mnih et al., 2015) showed that deep neural network policies can be trained using Q-learning by incorporating experience replay and target networks.
Several works have extended DQN to incorporate bias correction as in DDQN (Van Hasselt et al., 2015), prioritized experience replay (Schaul et al., 2015), architectural improvements (Wang et al., 2016), and distributional value learning (Bellemare et al., 2017; Dabney et al., 2017; 2018).
Besides value learning, agents based on policy gradients have targeted the Atari benchmark, such as ACER (Schulman et al., 2017a), PPO (Schulman et al., 2017a), ACKTR (Wu et al., 2017), and Reactor (Gruslys et al., 2017).
Another line of work has focused on improving performance by distributing data collection, often while increasing the budget of environment steps beyond 200M (Mnih et al., 2016; Schulman et al., 2017b; Horgan et al., 2018;
Kapturowski et al., 2018; Badia et al., 2020).
World models Several model-based agents focus on proprioceptive inputs (Watter et al., 2015; Gal et al., 2016; Higuera et al., 2018;
Henaff et al., 2018;
Chua et al., 2018; Wang et al., 2019; Wang and Ba, 2019), model images without using them for planning (Oh et al., 2015; Krishnan et al., 2015; Karl et al., 2016; Chiappa et al., 2017; Babaeizadeh et al., 2017; Gemici et al., 2017; Denton and Fergus, 2018; Buesing et al., 2018; Doerr et al., 2018; Gregor and Besse, 2018), or combine the beneﬁts of model-based and model-free approaches (Kalweit and Boedecker, 2017; Nagabandi et al., 2017;
Weber et al., 2017; Kurutach et al., 2018; Buckman et al., 2018; Ha and Schmidhuber, 2018; Wayne et al., 2018; Igl et al., 2018; Srinivas et al., 2018; Lee et al., 2019).
Risi and Stanley (2019) optimize et al.
combine reinforce and reparameterization gradients.
Most world model agents with image inputs have thus far been limited to relatively simple control tasks (Watter et al., 2015; Ebert et al., 2017; Ha and Schmidhuber, 2018; Hafner et al., 2018; Zhang et al., 2019; Hafner et al., 2019).
We explain the two model-based approaches that were applied to Atari in detail below.
SimPLe The SimPLe agent (Kaiser et al., 2019) learns a video prediction model in pixel-space and uses its predictions to train a PPO agent (Schulman et al., 2017a), as shown in Table 3.
The model directly predicts each frame from the previous four frames and receives an additional discrete latent variable as input.
The authors evaluate SimPLe on a subset of Atari games for 400k and 2M environment steps, after which they report diminishing returns.
Some recent model-free methods have followed the comparison at 400k steps (Srinivas et al., 2020; Kostrikov et al., 2020).
However, the highest performance achieved in this data-efﬁcient regime is a gamer normalized median score of 0.28 (Kostrikov et al., 2020) that is far from human-level performance.
Instead, we focus on the well-established and competitive evaluation after 200M frames, where many successful model-free algorithms are available for comparison.
MuZero The MuZero agent (Schrittwieser et al., 2019) learns a sequence model of rewards and values (Oh et al., 2017) to solve reinforcement learning tasks via Monte-Carlo Tree Search (MCTS;
Coulom, 2006; Silver et al., 2017).
The sequence model is trained purely by predicting task-speciﬁc information and does not incorporate explicit representation learning using the images, as shown in Table 3.
MuZero shows that with signiﬁcant engineering effort and a vast computational budget, planning can achieve impressive performance on several board games and deterministic Atari games.
However, MuZero is not publicly available, and it would require over 2 months to train an Atari agent on one GPU.
By comparison, DreamerV2 is a simple algorithm that achieves human-level performance on Atari on a single GPU in 10 days, making it reproducible for many researchers.
Moreover, the advanced planning components of MuZero are complementary and could be applied to the accurate world models learned by DreamerV2.
DreamerV2 leverages the additional learning signal provided by the input images, analogous to recent successes by semi-supervised image classiﬁcation (Chen et al., 2020;
He et al., 2020; Grill et al., 2020).
D ISCUSSION
We present DreamerV2, a model-based agent that achieves human-level performance on the Atari 200M benchmark by learning behaviors purely from the latent-space predictions of a separately trained world model.
Using a single GPU and a single environment instance, DreamerV2 outperforms top model-free single-GPU agents Rainbow and IQN using the same computational budget and training time.
To develop DreamerV2, we apply several small modiﬁcations to the Dreamer agent (Hafner et al., 2019).
We conﬁrm experimentally that learning a categorical latent space and using KL balancing improves the performance of the agent. Moreover, we ﬁnd the DreamerV2 relies on image information for learning generally useful representations — its performance is not impacted by whether the representations are especially learned for predicting rewards.
DreamerV2 serves as proof of concept, showing that model-based RL can outperform top model-free algorithms on the most competitive RL benchmarks, despite the years of research and engineering effort that modern model-free agents rest upon.
Beyond achieving strong performance on individual tasks, world models open avenues for efﬁcient transfer and multi-task learning, sample-efﬁcient learning on physical robots, and global exploration based on uncertainty estimates.
Acknowledgements We thank our anonymous reviewers for their feedback and Nick Rhinehart for an insightful discussion about the potential beneﬁts of categorical latent variables.
C S UMMARY OF M ODIFICATIONS
To develop DreamerV2, we used the Dreamer agent (Hafner et al., 2019) as a starting point.
This subsection describes the changes that we applied to the agent to achieve high performance on the
Atari benchmark, as well as the changes that were tried but not found to increase performance and thus were not not included in DreamerV2.
Summary of changes that were tried and were found to help:
• Categorical latents Using categorical latent states using straight-through gradients in the world model instead of Gaussian latents with reparameterized gradients.
• KL balancing Separately scaling the prior cross entropy and the posterior entropy in the KL loss to encourage learning an accurate temporal prior, instead of using free nats.
• Reinforce only Reinforce gradients worked substantially better for Atari than dynamics backpropagation.
For continuous control, dynamics backpropagation worked substantially better.
• Model size Increasing the number of units or feature maps per layer of all model components, resulting in a change from 13M parameters to 22M parameters.
• Policy entropy Regularizing the policy entropy for exploration both in imagination and during data collection, instead of using external action noise during data collection.
Summary of changes that were tried but were found to not help substantially:
• Binary latents Using a larger number of binary latents for the world model instead of categorical latents, which could have encouraged a more disentangled representation, was worse.
• Long-term entropy Including the policy entropy into temporal-difference loss of the value function, so that the actor seeks out states with high action entropy beyond the planning horizon.
• Mixed actor gradients Combining Reinforce and dynamics backpropagation gradients for learning the actor instead of Reinforce provided marginal or no beneﬁts.
• Scheduling Scheduling the learning rates, KL scale, actor entropy loss scale, and actor gradient mixing (from 0.1 to 0) provided marginal or no beneﬁts.
• Layer norm Using layer normalization in the GRU that is used as part of the RSSM latent transition model, instead of no normalization, provided no or marginal beneﬁts.
Due to the large computational requirements, a comprehensive ablation study on this list of all changes is unfortunately infeasible for us.
This would require 55 tasks times 5 seeds for 10 days per change to run, resulting in over 60,000 GPU hours per change.
However, we include ablations for the most important design choices in the main text of the paper.
D
H YPER P
[Table] E A C
J
[Table]
m e
[Table]
o n d
U p N
D o w n K r u ll
G o p h
e r
D e m o n A tt a c k
A ss a u l t
R o a d
R unn e r
T i m e
P il o t
B r e a k o u t
A s t e r i x
P h
o e n i x
Q b e r t
A t l a n t i s
[Table]
xx o n
I c e H o c k e y
W i z a r d
O f W o r
Y a r s R e
[Table]
e n g e
N a m e
T h i
[Table]
m
[Table]
F
[Table]
M a s t e r
R
[Table]
a n k
C r a
[Table]
y
[Table]
m
[Table]
e
[Table]
A s
[Table]
e r o i d s
F r o s t
[Table]
i t e C [Table] n
[Table]
i p e d
[Table]
r
[Table]
i
[Table]
a r
[Table]
m
[Table]
i d
[Table]
K
[Table]
a
[Table]
oo
F i
[Table]
i n
[Table]
r b y
[Table]
m i
[Table]
B a
[Table]
k
H
[Table]
i s
[Table]
k
[Table]
a m
[Table]
i
[Table]
e
[Table]
a i d
[Table]
n g
M
[Table]
P a
[Table]
m a n
B e r
[Table]
r k P i t f a ll F r ee w a y P
[Table]
B a tt l e
Z o n e
P r i v a t e
E y e
S o l a r i s
M o n t e z u m a
R e v .
A li e n
S e a q u e s t
B o x i n
[Table]
H e r o T e nn i s E n d u r o C h o pp e r C o m .
V e n t
u
r e Sp a c e I n v a d e r s D o u b l e D un k
S t a r G unn e r
V i
d e o
P i n b a ll
DreamerV2 vs IQN
J a m e s
B o n d
U p N
D o w n K r u ll A ss a u l t
G o p h
e r
D e m o n A tt a c k
R o a d
R unn e r
T i m e
P il o t
A t l a n t i s
B r e a k o u t
A s t e r i x
P h o e n i x Q b e r t
Z a xx o n
I c e H o c k e y Y a r s R e v e n g e
K un g
F u M a s t e r
S k ii n g R o b o t a n k
W i z a r d
O f W o r
N a m e
T h
i s G a m
e T e nn i s A s t e r o i d s
G r a v i t a r
B e a m
R i d e r
F r o s t b i t e C r a z y
C li m b e r
C e n t
i p e d e
K a n g a r oo F i s h i n g D e r b y
M s P a c m a n T u t a n k h a m A li e n
B a n k
H e i s t
B o w li n g
A m i d a r
B a tt l e
Z o n e P i t
f a ll F r ee w a y B e r z e r k
P o n g S e a q u e s t
S o l a r i s M o n t e z u m a R e v .
P r i v a t e
E y e R i v e rr a i d
B o x i n g E n d u r o H e r o
Sp a c e I n v a d e r s
V e n t
u
r e
C h
o pp e r C o m .
D o u b l e D un k S t a r G unn e r
V i
d e o
P i n b a ll
DreamerV2 vs Rainbow
J a m e s
B o n d
U p N
D o w n
A ss a u l t D e m o n A tt a c k K r u ll
G o p h
e r R o a d
R unn e r T i m e P il o t A t l a n t i s
D o u b l e D un k A s t e r i x P h
o e n i x
Q b e r t Z a xx o n B r e a k o u t Y a r s R e v e n g e
I c e H o c k e y
W i z a r d O f W o r
K a n g a r oo R o b o t a n k K un g F u M a s t e r
F r o s t b i t e
C r a z y
C li m b e r F i s h
i n g D e r b y
S k ii n g
G r a v i t a r B o x i n g
A s t e r o i d s
B e a m
R i d e r
A m i d a r
B a n k
H e i s t
E n d u r o C e n t
i p e d e B a tt l e Z o n e
N a m e
T h
i s G a m e
M s P a c m a n A li e n
R i v e rr a i d
T u t a n k h a m
B o w li n g
B e r z e r k
P o n g P i t
f a ll
F r ee w a y
P r i v a t e
E y e
S o l a r i s
M o n t e z u m a
R e v . H e r o
C h
o pp e r C o m .
T e nn i s S e a q u e s t
Sp a c e I n v a d e r s
V e n t
u
r e
S t a r G unn e r
V i
d e o
P i n b a ll
DreamerV2 vs C
J a m e s
B o n d
U p N
D o w n
A ss a u l t
D e m o n A tt a c k K r u ll
G o p h
e r
R o a d
R unn e r
T i m e
P il o t
D o u b l e
D un k
A s t e r i x A t l a n t i s
B r e a k o u t
P h
o e n i x Q b e r t
Z a xx o n
I c e H o c k e y
F r o s t b i t e Y a r s R e v e n g e
W i z a r d O f W o r
C r a z y
C li m b e r
R o b o t a n k K un g F u M a s t e r
N a m e
T h
i s G a m e
F i s h
i n g D e r b y
E n d u r o B o x i n g
G r a v i t a r
T u t a n k h a m T e nn
i s
C e n t i p e d e
A s t e r o i d s K a n g a r oo
A m i d a r
B e a m
R i d e r
B a n k
H e i s t
B a tt l e
Z o n e S k ii n g Sp a c e I n v a d e r s
M s P a c m a n
R i v e rr a i d
F r ee w a y A li e n H e r o
S e a q u e s t B o w li n g
B e r z e r k
P o n g
P r i v a t e E y e
C h
o pp e r C o m .
M o n t e z u m a
R e v .
P i t
f a ll
V e n t
u
r e
S o l a r i s
S t a r G unn e r
V i
d e o
P i n b a ll
[Figure]
F
[Figure]
ODEL -F
[Figure]
C [Figure] Tutankham
[Figure]
G L ATENTS AND KL B ALANCING A BLATIONS
[Figure]
H R EPRESENTATION L EARNING A BLATIONS
[Figure]
I P OLICY L EARNING A BLATIONS
[Figure]
J A DDITIONAL A BLATIONS
[Figure]
K
A TARI T ASK S CORES
Baselines
Algorithms
Task Random
Gamer
Record
Rainbow
IQN
DreamerV
Alien     3967 Amidar     2577 Assault     23625 Asterix     72311 Asteroids     41526 Atlantis     {+978778 Bank Heist     1126 Battle Zone     40325 Beam Rider     18646 Berzerk     810 Bowling     49 Boxing     92 Breakout     312 Centipede     11883 Chopper Command     2861 Crazy Climber     
+}
Demon Attack
Double Dunk - -    17 Enduro     1656 Fishing Derby - -    65 Freeway     33 Frostbite     11384 Gopher     92282 Gravitar     3789 Hero     21868 Ice Hockey -    - 26 James Bond
Kangaroo
Krull     50061 Kung Fu Master     62741 Montezuma Revenge     81 Ms Pacman     5652 Name This Game     14649 Phoenix     49375 Pitfall -   - - 0 Pong20 Private Eye     2198 Qbert     {+
+} Riverraid     16351 Road Runner     203576 Robotank     78 Seaquest
Skiing - - - - - -9299 Solaris     922 Space Invaders     2474 Star Gunner     [-
-]7800 Tennis - -    14 Time Pilot
Tutankham
[Table]