summaries: This paper presents the idea of self-consistent reinforcement learning.  By enforcing "consistency" between value functions and approximate  (learned) models, a model-based learning algorithm can use synthetic experience generated from the approximate model.  This paper presents a few minor variations on this theme, and explores the results empirically. This paper considers the problem of model-based reinforcement learning. The authors introduce a new loss, which drives the learned model and value function to be consistent with each other, rather than the model being consistent with the real environment and the value function being consistent with the real environment and the learned model. Experiments show that the proposed self-consistency loss can improve the sample efficiency and final performance.  This work proposes to improve model-based RL methods by enforcing the model and value learned to be “self-consistent”, i.e. to satisfy the Bellman eqn where both the Bellman operator and value function are defined in terms of the model. The motivation behind this is that in classic MBRL, the model and value function are learned separately, and the value function is typically learned to be consistent with the model but not vice versa. The authors propose to enforce self-consistency by adding a "self-consistency loss” (L_SC) to the base loss and jointly learning the model and value functions. L_SC is the squared TD error with a stop-gradient on the target and is calculated using rollouts from the model. Although in MuZero/Muesli the model and value functions are learned jointly as well, the targets of the loss are all defined with respect to data from the true environment and there is not term enforcing the “self-consistency” between model and value functions. Experimental evaluations on a selection of Atari games show that jointly updating the model and value functions with the additional L_SC term leads to improved sample efficiency as compared to Dyna and a model-free baseline. The authors also empirically study the search control problem. The paper offers a new approach to model-based reinforcement learning with their idea of self-consistency of models and values. In the traditional (Dyna) model-based RL paradigm, an approximate model is learned with ground truth transitions and values (and policies) are updated to be consistent with the learned model. The proposed self-consistency update however, formulates a new update to the approximate model so as to make it consistent with the current value estimates using completely imagined (virtual) experience. This update is inspired by minimizing the bellman residual of the approximate model and value for a given policy (since for the true value and model, the bellman equation is satisfied and the residual is zero). An empirical analysis is presented for a set of variations of the proposed self-consistency objective with two types of (grounded) model updates -- MLE (maximum-likelihood) and value equivalent updates. In both tabular and function approximate settings, improved sample efficiency is demonstrated by the proposed method.
abstractText: Learned models of the environment provide reinforcement learning (RL) agents with flexible ways of making predictions about the environment. In particular, models enable planning, i.e. using more computation to improve value functions or policies, without requiring additional environment interactions. In this work, we investigate a way of augmenting model-based RL, by additionally encouraging a learned model and value function to be jointly self-consistent. Our approach differs from classic planning methods such as Dyna, which only update values to be consistent with the model. We propose multiple self-consistency updates, evaluate these in both tabular and function approximation settings, and find that, with appropriate choices, self-consistency helps both policy evaluation and control.
authors.name: Gregory Farquhar DeepMind
authors.name: Kate Baumli DeepMind
authors.name: Zita Marinho
references.authors: A. Abdolmaleki J.T. Springenberg Y. Tassa R. Munos N. Heess M. Riedmiller
references.title: Maximum a Posteriori Policy Optimisation
references.venue: International Conference on Learning Representations
references.authors: T.W. Archibald K. McKinnon L.C. Thomas
references.title: On the generation of markov decision processes
references.venue: Journal of the Operational Research Society, 46(3):354–361
references.authors: I. Babuschkin K. Baumli A. Bell S. Bhupatiraju J. Bruce P. Buchlovsky D. Budden T. Cai A. Clark I. Danihelka C. Fantacci J. Godwin C. Jones T. Hennigan M. Hessel S. Kapturowski T. Keck I. Kemaev M. King L. Martens V. Mikulik T. Norman J. Quan G. Papamakarios R. Ring F. Ruiz A. Sanchez R. Schneider E. Sezener S. Spencer S. Srinivasan W. Stokowiec
references.title: and F
references.venue: Viola. The DeepMind JAX Ecosystem
references.authors: L. Baird
references.title: Residual algorithms: Reinforcement learning with function approximation
references.venue: Machine Learning Proceedings 1995, pages 30–37. Elsevier
references.authors: P. Baudiš J.L. Gailly
references.title: Pachi: State of the art open source Go program
references.venue: Advances in computer games, pages 24–38. Springer
references.authors: M.G. Bellemare Y. Naddaf J. Veness M. Bowling
references.title: The arcade learning environment: An evaluation platform for general agents
references.venue: Journal of Artificial Intelligence Research, 47:253–279
references.authors: R. Bellman
references.title: A Markovian decision process
references.venue: Journal of Mathematics and Mechanics, 6(5): 679–684
references.authors: O. Bojar A. Tamchyna
references.title: Improving translation model by monolingual data
references.venue: Proceedings of the Sixth Workshop on Statistical Machine Translation, pages 330–336
references.authors: J. Bradbury R. Frostig P. Hawkins M.J. Johnson C. Leary D. Maclaurin G. Necula A. Paszke J. VanderPlas S. Wanderman-Milne
references.title: and Q
references.venue: Zhang. JAX: composable transformations of Python+NumPy programs
references.authors: A. Byravan J.T. Springenberg A. Abdolmaleki R. Hafner M. Neunert T. Lampe N. Siegel N. Heess M. Riedmiller
references.title: Imagined value gradients: Model-based policy optimization with tranferable latent dynamics models
references.venue: Conference on Robot Learning, pages 566–589. PMLR
references.authors: V. Chelu D. Precup
references.title: and H
references.venue: P. van Hasselt. Forethought and Hindsight in Credit Assignment. In Advances in Neural Information Processing Systems, volume 33, pages 2270–2281
references.authors: S. Edunov M. Ott M. Auli D. Grangier
references.title: Understanding back-translation at scale
references.venue: arXiv preprint arXiv:1808.09381
references.authors: L. Espeholt H. Soyer R. Munos K. Simonyan V. Mnih T. Ward Y. Doron V. Firoiu T. Harley I. Dunning
references.title: et al
references.venue: Impala: Scalable distributed deep-rl with importance weighted actor-learner architectures. In International Conference on Machine Learning, pages 1407–1416. PMLR
references.authors: A.M. Farahmand
references.title: Iterative Value-Aware Model Learning
references.venue: NeurIPS, pages 9090–9101
references.authors: A.M. Farahmand A. Barreto D. Nikovski
references.title: Value-aware loss function for model-based reinforcement learning
references.venue: Artificial Intelligence and Statistics, pages 1486–1494. PMLR
references.authors: G. Farquhar T. Rocktäschel M. Igl S. Whiteson
references.title: Treeqn and atreec: Differentiable tree-structured models for deep reinforcement learning
references.venue: arXiv preprint arXiv:1710.11417
references.authors: A. Filos C. Lyle Y. Gal S. Levine N. Jaques G. Farquhar
references.title: PsiPhi-Learning: Reinforcement Learning with Demonstrations using Successor Features and Inverse Temporal Difference Learning
references.venue: arXiv preprint arXiv:2102.12560
references.authors: K. Gregor D.J. Rezende F. Besse Y. Wu H. Merzic A. Oord
references.title: Shaping belief states with generative environment models for rl
references.venue: arXiv preprint arXiv:1906.09237
references.authors: C. Grimm A. Barreto S. Singh D. Silver
references.title: The Value Equivalence Principle for Model- Based Reinforcement Learning
references.venue: Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual
references.authors: A. Guez F. Viola T. Weber L. Buesing S. Kapturowski D. Precup D. Silver N. Heess
references.title: Value-driven hindsight modelling
references.venue: arXiv preprint arXiv:2002.08329
references.authors: D. Ha J. Schmidhuber
references.title: World models
references.venue: arXiv preprint arXiv:1803.10122
references.authors: D. Hafner T. Lillicrap J. Ba M. Norouzi
references.title: Dream to control: Learning behaviors by latent imagination
references.venue: arXiv preprint arXiv:1912.01603
references.authors: D. Hafner T. Lillicrap M. Norouzi J. Ba
references.title: Mastering Atari with Discrete World Models
references.venue: arXiv e-prints, art
references.authors: J.B. Hamrick A.L. Friesen F. Behbahani A. Guez F. Viola S. Witherspoon T. Anthony L.H. Buesing P. Veličković T. Weber
references.title: On the role of planning in model-based deep reinforcement learning
references.venue: International Conference on Learning Representations
references.authors: M. Hessel I. Danihelka F. Viola A. Guez S. Schmitt L. Sifre T. Weber D. Silver
references.title: and H
references.venue: van Hasselt. Muesli: Combining Improvements in Policy Optimization. CoRR, abs/2104.06159
references.authors: M. Hessel M. Kroiss A. Clark I. Kemaev J. Quan T. Keck F. Viola
references.title: and H
references.venue: van Hasselt. Podracer architectures for scalable Reinforcement Learning. CoRR, abs/2104.06272
references.authors: G.Z. Holland E.J. Talvitie M. Bowling
references.title: The effect of planning shape on dyna-style planning in high-dimensional state spaces
references.venue: arXiv preprint arXiv:1806.01825
references.authors: M. Jaderberg V. Mnih W.M. Czarnecki T. Schaul J.Z. Leibo D. Silver K. Kavukcuoglu
references.title: Reinforcement learning with unsupervised auxiliary tasks
references.venue: arXiv preprint arXiv:1611.05397
references.authors: L.P. Kaelbling T. Lozano-Pérez
references.title: Hierarchical Task and Motion Planning in the Now
references.venue: Proceedings of the 1st AAAI Conference on Bridging the Gap Between Task and Motion Planning, AAAIWS’10-01, page 33–42. AAAI Press
references.authors: G. Kahn A. Villaflor B. Ding P. Abbeel S. Levine
references.title: Self-supervised deep reinforcement learning with generalized computation graphs for robot navigation
references.venue: 2018 IEEE International Conference on Robotics and Automation (ICRA), pages 5129–5136. IEEE
references.authors: L. Kaiser M. Babaeizadeh P. Milos B. Osinski R.H. Campbell K. Czechowski D. Erhan C. Finn P. Kozakowski S. Levine R. Sepassi G. Tucker H. Michalewski
references.title: Model-Based Reinforcement Learning for Atari
references.venue: CoRR, abs/1903.00374
references.authors: P.R. Kumar P. Varaiya
references.title: Stochastic systems: Estimation
references.venue: identification, and adaptive control. SIAM
references.authors: A.X. Lee A. Nagabandi P. Abbeel S. Levine
references.title: Stochastic latent actor-critic: Deep reinforcement learning with a latent variable model
references.venue: arXiv preprint arXiv:1907.00953
references.authors: M.C. Machado M.G. Bellemare E. Talvitie J. Veness M. Hausknecht M. Bowling
references.title: Revisiting the arcade learning environment: Evaluation protocols and open problems for general agents
references.venue: Journal of Artificial Intelligence Research, 61:523–562
references.authors: H.R. Maei
references.title: Gradient Temporal-Difference Learning Algorithms
references.venue: PhD thesis, CAN
references.authors: T.M. Moerland J. Broekens C.M. Jonker
references.title: Model-based reinforcement learning: A survey
references.venue: arXiv preprint arXiv:2006.16712
references.authors: R. Munos T. Stepleton A. Harutyunyan M.G. Bellemare
references.title: Safe and efficient off-policy reinforcement learning
references.venue: Proceedings of the 30th International Conference on Neural Information Processing Systems, pages 1054–1062
references.authors: J. Oh X. Guo H. Lee R. Lewis S. Singh
references.title: Action-conditional video prediction using deep networks in atari games
references.venue: arXiv preprint arXiv:1507.08750
references.authors: J. Oh S. Singh H. Lee
references.title: Value prediction network
references.venue: arXiv preprint arXiv:1707.03497
references.authors: Y. Pan J. Mei A.-M. Farahmand
references.title: Frequency-based Search-control in Dyna
references.venue: International Conference on Learning Representations
references.authors: T. Pohlen B. Piot T. Hester M.G. Azar D. Horgan D. Budden G. Barth-Maron H. Van Hasselt J. Quan M. Večerík
references.title: et al
references.venue: Observe and look further: Achieving consistent performance on atari. arXiv preprint arXiv:1805.11593
references.authors: M.L. Puterman
references.title: Markov Decision Processes: Discrete Stochastic Dynamic Programming
references.venue: John Wiley & Sons, Inc., USA, 1st edition
references.authors: S. Racanière T. Weber D.P. Reichert L. Buesing A. Guez D. Rezende A.P. Badia O. Vinyals N. Heess Y. Li
references.title: et al
references.venue: Imagination-augmented agents for deep reinforcement learning. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pages 5694–5705
references.authors: D.J. Rezende I. Danihelka G. Papamakarios N.R. Ke R. Jiang T. Weber K. Gregor H. Merzic F. Viola J. Wang
references.title: et al
references.venue: Causally correct partial models for reinforcement learning. arXiv preprint arXiv:2002.02836
references.authors: J. Richalet A. Rault J. Testud J. Papon
references.title: Model predictive heuristic control
references.venue: Automatica (journal of IFAC), 14(5):413–428
references.authors: J. Schmidhuber
references.title: An on-line algorithm for dynamic reinforcement learning and planning in reactive environments
references.venue: 1990 IJCNN international joint conference on neural networks, pages 253–258. IEEE
references.authors: J. Schrittwieser I. Antonoglou T. Hubert K. Simonyan L. Sifre S. Schmitt A. Guez E. Lockhart D. Hassabis T. Graepel T. Lillicrap D. Silver
references.title: Mastering Atari, Go, chess and shogi by planning with a learned model
references.authors: J. Schrittwieser T. Hubert A. Mandhane M. Barekatain I. Antonoglou D. Silver
references.title: Online and Offline Reinforcement Learning by Planning with a Learned Model
references.authors: D. Silver J. Veness
references.title: Monte-Carlo Planning in Large POMDPs
references.venue: Advances in Neural Information Processing Systems, volume 23, pages 2164–2172. Curran Associates, Inc.
references.authors: D. Silver
references.title: H
references.venue: van Hasselt, M. Hessel, T. Schaul, A. Guez, T. Harley, G. Dulac-Arnold, D. Reichert, N. Rabinowitz, A. Barreto, et al. The predictron: End-to-end learning and planning. In International Conference on Machine Learning, pages 3191–3199. PMLR
references.authors: R.S. Sutton
references.title: Dyna, an Integrated Architecture for Learning, Planning, and Reacting
references.venue: ISSN 0163-5719
references.authors: R.S. Sutton A.G. Barto
references.title: Reinforcement Learning: An Introduction
references.venue: The MIT Press, Cambridge, MA
references.authors: A. Tamar Y. Wu G. Thomas S. Levine P. Abbeel
references.title: Value iteration networks
references.venue: arXiv preprint arXiv:1602.02867
references.authors: H. van Hasselt M. Hessel J. Aslanides
references.title: When to use parametric models in reinforcement learning
references.venue: In Advances in Neural Information Processing Systems,
references.authors: P.J. Werbos
references.title: Learning how the world works: Specifications for predictive networks in robots and brains
references.venue: Proceedings of IEEE International Conference on Systems, Man and Cybernetics, NY
references.authors: T. Yu C. Lan W. Zeng M. Feng Z. Chen
references.title: PlayVirtual: Augmenting Cycle-Consistent Virtual Trajectories for Reinforcement Learning
references.venue: arXiv preprint arXiv:2106.04152
references.authors: S. Zhang W. Boehmer S. Whiteson
references.title: Deep Residual Reinforcement Learning
references.venue: In AAMAS 2020: Proceedings of the Nineteenth International Joint Conference on Autonomous Agents and Multi-Agent Systems,
references.authors: J.-Y. Zhu T. Park P. Isola A.A. Efros
references.title: Unpaired image-to-image translation using cycle-consistent adversarial networks
references.venue: Proceedings of the IEEE international conference on computer vision, pages 2223–2232
sections.text: Learned models of the environment provide reinforcement learning (RL) agents with flexible ways of making predictions about the environment. In particular, models enable planning, i.e. using more computation to improve value functions or policies, without requiring additional environment interactions. In this work, we investigate a way of augmenting model-based RL, by additionally encouraging a learned model and value function to be jointly self-consistent. Our approach differs from classic planning methods such as Dyna, which only update values to be consistent with the model. We propose multiple self-consistency updates, evaluate these in both tabular and function approximation settings, and find that, with appropriate choices, self-consistency helps both policy evaluation and control.
sections.heading: 1 Introduction
sections.text: Models of the environment provide reinforcement learning (RL) agents with flexible ways of making predictions about the environment. They have been used to great effect in planning for action selection [45, 29, 49], and for learning policies or value functions more efficiently [51]. Learning models can also assist representation learning, serving as an auxiliary task, even if not used for planning [25, 48]. Traditionally, models are trained to be consistent with experience gathered in the environment. For instance, an agent may learn maximum likelihood estimates of the reward function and state-transition probabilities, based on the observed rewards and state transitions. Alternatively, an agent may learn a model that only predicts behaviourally-relevant quantities like rewards, values, and policies [47].
  In this work, we study a possible way to augment model-learning, by additionally encouraging a learned model m̂ and value function v̂ to be jointly self-consistent, in the sense of jointly satisfying the Bellman equation with respect to m̂ and v̂ for the agent’s policy π. Typical methods for using models in learning, like Dyna [51], treat the model as a fixed best estimate of the environment, and only update the value to be consistent with the model. Self-consistency, by contrast, jointly updates the model and value to be consistent with each other. This may allow information to flow more flexibly between the learned reward function, transition model, and approximate value. Since the true model and value are self-consistent, this type of update may also serve as a useful regulariser.
  We investigate self-consistency both in a tabular setting and at scale, in the context of deep RL. There are many ways to formulate a model-value update based on the principle of self-consistency, but we find that naive updates may be useless, or even detrimental. However, one variant based on a semi-gradient temporal difference objective can accelerate value learning and policy optimisation. We evaluate different search-control strategies (i.e. the choice of states and actions used in the selfconsistency update), and show that self-consistency can improve sample efficiency in environments such as Atari, Sokoban and Go. We conclude with experiments designed to shed light on the mechanisms by which our proposed self-consistency update aids learning.
  35th Conference on Neural Information Processing Systems (NeurIPS 2021).
sections.heading: 2 Background
sections.text: We adopt the Markov Decision Process (MDP) formalism for an agent interacting with an environment [7, 42]. The agent selects an action At ∈ A in state St ∈ S on each time step t, then observes a reward Rt+1 and transitions to the successor state St+1. The environment dynamics is given by a “true” model m∗ = (r, P ), consisting of reward function r(s, a) and transition dynamics P (s′|s, a). The behaviour of the agent is characterized by a policy π : S → ∆A, a mapping from states to the space of probability distributions over actions. The agent’s objective is to update its policy to maximise the value vπ(s) = Em∗,π [∑∞ j=0 γ jr(St+j,At+j) | St = s ]
  of each state. We are interested in model-based approaches to this problem, where an agent uses a learned model of the environment m̂ = (r̂, P̂ ), possibly together with a learned value function v̂(s) ≈ vπ , to optimise π. The simplest approach to learning such a model is to make a maximum likelihood estimate of the true reward and transition dynamics, based on the agent’s experience [32]. The model can then be used to perform updates for arbitrary states and action pairs, entirely in imagination. Dyna [51] is one algorithm with this property, that has proven effective in improving the data efficiency of RL [22, 31].
  An alternative model-learning objective is value equivalence1 i.e. equivalence of the true and learned models in terms of the induced values for the agent’s policy. This can be formalised as requiring the induced Bellman operator of the model to match that of the environment:
  T πm∗vπ = T πm̂vπ, (1)
  where the Bellman operator for a model m̂ is defined by T πm̂v = Em̂,π [r(s, a) + γv(s′)]. Such models do not need to capture every detail of the environment, but must be consistent with it in terms of the induced Bellman operators applied to certain functions (in this case, the agent’s value vπ).
  We take a particular interest in value equivalent models for two reasons. First, they are used in stateof-the-art agents, as described in the next section and used as baselines in our deep RL experiments. Second, these algorithms update the model using a value-based loss, like the self-consistency updates we will study in this work. We describe this connection further in Section 3.3.
sections.heading: 2.1 Value equivalent models in deep RL
sections.text: A specific flavour of value equivalent model is used by the MuZero [47] and Muesli [25] agents. Both use a representation function (encoder) hθ to construct a state zt = hθ(o1:t) from a history of observations o1:t2. We define a deterministic recurrent model m̂ ≡ mθ in this latent space. On each step k the model, conditioned on an action, predicts a new latent state zkt and reward r̂ k t ; the agent also predicts from each zkt a value v̂ k t and a policy π̂ k t . We use superscripts to denote time steps in the model: i.e., zkt is the latent state after taking k steps with the model, starting in the root state z 0 t ≡ zt.
  Muesli and MuZero unroll such a model for K steps, conditioning on a sequence of actions taken in the environment. The learned components are then trained end-to-end, using data gathered from interaction with the environment, D∗π , by minimizing the loss function
  Lbaset (m̂, v̂, π̂|D∗π) = ED∗π K∑ k=0 [ `r(rtargett+k , r̂ k t ) + ` v(vtargett+k , v̂ k t ) + ` π(πtargett+k , π̂ k t ) ] . (2)
  This loss is the sum of a reward loss `r, a value loss `v and a policy loss `π . Note that there is no loss on the latent states zkt : e.g. these are not required to match zt+k = hθ(o1:t+k). The targets r target t+k for the reward loss are the true rewards Rt+k observed in the environment. The value targets are constructed from sequences of rewards and n-bootstrap value estimates vtargett+k = ∑n j=1 γ j−1rt+k+j + γ nṽt+k+n. The bootstrap value estimates ṽ, as well as the policy targets, are constructed using the model m̂. This is achieved in MuZero by applying Monte-Carlo tree search, and, in Muesli, by using one-step look-ahead to create MPO-like [1] targets. Muesli also employs a policy-gradient objective which does not update the model. We provide some further details about Muesli in Appendix B.2, as we use
  1We borrow the terminology from Grimm et al. [19], who provided a theoretical framework to reason about such models. Related ideas were also introduced under the name ‘value aware’ model learning [15, 14]
  2We denote sequences of outcomes of random variables O1 = o1, . . . , Ot = ot as o1:t for simplicity.
  Algorithm 1: Model-based RL with joint grounded and self-consistency updates. input : initial m̂, v̂, π output :estimated value v̂ ≈ vπ and/or optimal policy π∗ repeat
  Collect D∗π from m∗ following π Compute grounded loss: Lbase(m̂, v̂, π|D∗π) // e.g. Eq.(2) Generate D̂µ from m̂ following µ Compute self-consistency loss: Lsc(m̂, v̂|D̂µ) // see Eqs.(4,5,6) Update m̂, v̂, π by minimising (e.g., with SGD): L = Lbase + Lsc
  until convergence;
  it as a baseline for our deep RL experiments. For comprehensive descriptions of MuZero and Muesli we refer to the respective publications [47, 25].
  In both cases, the model is used to construct targets based on multiple imagined actions, but the latent states whose values are updated by optimising the objective (2) always correspond to real states that were actually encountered by the agent when executing the corresponding action sequence in its environment. Value equivalent models could also, in principle, update state and action pairs entirely in imagination (similarly to Dyna) but, to the best of our knowledge, this has not been investigated in the literature. Our proposed self-consistency updates provide one possible mechanism to do so.
sections.heading: 3 Self-consistent models and values
sections.text: A particular model m̂ and policy π induce a corresponding value function vπm̂, which satisfies a Bellman equation T πm̂vπm̂ = vπm̂. We describe model-value pairs which satisfy this condition as self-consistent. Note that the true model m∗ and value function vπ are self-consistent by definition.
  If an approximate model m̂ and value v̂ are learned independently, they may only be asymptotically self-consistent, in that the model is trained to converge to the true model, and the estimated value to the true value. Model-based RL algorithms, such as Dyna, introduce an explicit drive towards consistency throughout learning: the value is updated to be consistent with the model, in addition to the environment. However, the model is only updated to be consistent with transitions in the real environment D∗π , and not to be consistent with the approximate values. Instead, we propose to update both the model and values so that they are self-consistent with respect to trajectories D̂µ sampled by rolling out a model m̂, under action sequences sampled from some policy µ (with µ 6= π in general). We conjecture that allowing information to flow more freely between the learned rewards, transitions, and values, may make learning more efficient. Self-consistency may also implement a useful form of regularisation – in the absence of sufficient data, we might prefer a model and value to be selfconsistent. Finally, in the context of function approximation, it may help representation learning by constraining it to support self-consistent model-value pairs. In this way, self-consistency may also be valuable as an auxiliary task even if the model is not used for planning.
sections.heading: 3.1 Self-consistency updates
sections.text: For the model and value to be eventually useful, they must still be in some way grounded to the true environment: self-consistency is not all you need. We are therefore interested in algorithms that include both grounded model-value updates, and self-consistency updates. This may be implemented by alternating the two kind of updates, or in single optimisation step (c.f. Algorithm 1) by gathering both real D∗π and imagined D̂µ experience and then jointly minimize the loss
  L(m̂, v̂, π|D∗π + D̂µ) = Lbase(m̂, v̂, π|D∗π) + Lsc(m̂, v̂|D̂µ). (3)
  There are many possible ways to leverage the principle of self-consistency to perform the additional update to the model and value (Lsc). We will first describe several possible updates based on 1-step temporal difference errors computed from K-step model rollouts following µ = π, but we will later
  consider more general forms. The most obvious update enforces self-consistency directly:
  Lsc-residual(m̂, v̂) = Em̂,π [ K∑ k=0 ( r̂(sk, ak) + γv̂(sk+1)− v̂(sk) )2] . (4)
  When used only to learn values, updates that minimize this loss are known as “residual” updates. These have been used successfully in model-free and model-based deep RL [57], even without addressing the double sampling issue [4]. However, it has been observed in the model-free setting that residual algorithms can have slower convergence rates than the TD(0) update [4], and may fail to find the true value [35]. In our setting, the additional degrees of freedom, due to the loss depending on a learned model, could allow the system to more easily fall into degenerate self-consistent solutions (e.g. zero reward and values everywhere). To alleviate this concern, we can also design our self-consistent updates to mirror a standard TD update, by treating the entire target r̂(sk, ak) + γv̂(sk+1) as fixed:
  Lsc-direct(m̂, v̂) = Em̂,π [ K∑ k=0 ( ⊥ ( r̂(sk, ak) + γv̂(sk+1) ) − v̂(sk) )2] , (5)
  where ⊥ indicates a suppressed dependence (a “stop gradient” in the terminology of automatic differentiation). This is sometimes referred to as using the “direct” method, or as using a semigradient objective [52]. Dyna minimises this objective, but only updates the parameters of the value function (Fig. 1a). We propose to optimise the parameters of both the model and the value (Fig. 1b).
  For k = 0, this will not update the transition model, as v(s0) does not depend on it. This necessitates the use of multi-step model rollouts (k ≥ 1). Using multi-step model rollouts is also typically better in practice [27], at least for traditional model-based value learning. This form of the self-consistency update will also never update the reward model. We hypothesise this may be a desirable property, since the grounded learning of the reward model is typically well-behaved. Further, if the grounded model update enforces value equivalence with respect to the current policy’s value, the transition dynamics are policy-dependent, but the reward model may be stationary. Consequently, we expect this form of update may have a particular synergy with the value-equivalent setting.
  Alternatively, we consider applying a semi-gradient in the other direction:
  Lsc-reverse(m̂, v̂) = Em̂,π [ K∑ k=0 ( r̂(sk, ak) + γv̂(sk+1)−⊥ ( v̂(sk) ))2] (6)
  This passes information forward in model-time from the value to the reward and transition model, even if k = 0.
sections.heading: 3.2 Self-consistency in a tabular setting
sections.text: First, we instantiate these updates in a tabular setting, using the pattern from Algorithm 1, but alternating the updates to the model and value for the grounded and self-consistency losses rather than adding the losses together for a single joint update. At each iteration, we first collect a batch of transitions from the environment (s, a, r, s′) ∼ m∗. The reward model is updated as r̂(s, a)← r(s, a) + αr(r(s, a)− r̂(s, a)). We update the value with TD(0): v̂(s)← (1− αv)v̂(s) + αv(r(s, a) + γv̂(s ′)). Here, αr and αv are learning rates.
  Next, we update the model, using either a maximum likelihood approach or the value equivalence principle. The transition model P̂ is parameterised as a softmax of learned logits: P̂ (s′|s, a) = softmax(p̂(s, a))[s′]. To learn a maximum likelihood model we follow the gradient of log P̂ (s′|s, a). For a value equivalent model, we descend the gradient of the squared difference of next-state values under the model and environment: ( ∑ ŝ′,a π(a|s)P̂ (s′|s, a)v̂(ŝ′)− v̂(s′))2.
  Then, we update either the value only to be consistent with the model (Dyna), or update both the model and value to be self-consistent according to the objectives in the previous section. For control, we can construct an action-value estimate Q̂(s, a) = r̂(s, a) + γ ∑ s′ P̂ (s, a, s
  ′)v̂(s′) with the model m̂ = {r̂, P̂}, and act -greedily using Q̂.
sections.heading: 3.3 Self-consistency in deep RL
sections.text: Self-consistency may be applied to deep RL as well, by modifying a base agent that learns a differentiable model m̂ and value v̂ using the generic augmented loss (3). We follow the design of Muesli [25] for our baseline, using the objective (2) to update the encoder, model, value, and policy in a grounded manner. We then add to the loss an additional self-consistency objective that generalises to the latent state representation setting:
  Lscπ = Ez0∼Z0Ea1,...,aK∼µ [ K∑ k=1 lv ( Ĝπk:K , v(z k) )] . (7)
  The base objective (2) already jointly learns a model and value to minimise a temporal-difference value objective `v(vtarget, v̂). Our self-consistency update is thus closely related to the original value loss, but differs in two important ways. First, instead of using rewards and next states from the environment, the value targets Ĝπk:K are (K − k)-step bootstrapped value estimates constructed with rewards and states predicted by rolling out the model m̂. The reliance of MuZero-style VE on the environment for bootstrap targets is illustrated schematically in Figure 1c, in contrast to self-consistency. Second, because the targets do not rely on real interactions with the environment, we may use any starting state and sequence of actions, like in Dyna.
  Z0 denotes the distribution of starting latent states from which to roll out the model for K steps, and µ is the policy followed in the model rollout. When µ differs from π, we may use off-policy corrections to construct the target Ĝπk:K ; in our experiments, we use V-Trace [13]. For now, we default to µ = π, and to using the same distribution for Z0 as for the base objective. We revisit these choices in Section 4.2. Note that by treating different parts of the loss in 7 as fixed, we can recover the residual, direct, and reverse forms of self-consistency.
  The self consistency objective is illustrated schematically in Figure 1. Subfigures (a) and (b) contrast a Dyna update to the value function with the SC-Direct update, which uses the same objective to update both value and model. Subfigure (c) shows the type of value equivalent update used in MuZero and Muesli. The objective is similar to SC-Direct, but the value targets come from real experience. Consequently, the model unroll must use the actions that were taken by the agent in the environment. Self-consistency instead allows to update the value and model based on any trajectories rolled out in the model; we verify the utility of this flexibility in Section 4.2.
  Baseline Dyna SC-Residual SC-Direct SC-Reverse
  0 25 k 50 k0.0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  N or
  m al
  is ed
  v al
  ue e
  rr or
  Evaluation (MLE)
  0 25 k 50 k0.0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6 Evaluation (VE)
  0 25 k 50 k0.75
  0.80
  0.85
  0.90
  0.95
  1.00
  N or
  m al
  is ed
  v al
  ue
  Control (MLE)
  0 25 k 50 k0.75
  0.80
  0.85
  0.90
  0.95
  1.00 Control (VE)
  Number of iterations
  (a) Self-consistency in random tabular MDPs. Each experiment was run with 30 independent replicas using different random seeds. (Left) Normalised value prediction error for policy evaluation, using MLE and VE models respectively. (Right) Normalised policy values for control, using MLE and VE models respectively.
  0 100M 200M
  10
  5
  0
  5
  Av g.
  e pi
  so de
  r et
  ur n
  sokoban
  0 100M 200M 0
  8k
  16k
  24k alien
  0 100M 200M 0
  8k
  16k
  24k
  assault
  0 100M 200M 0
  10k
  20k
  30k asteroids
  0 100M 200M 0
  10k
  20k
  30k
  wizard
  0 100M 200M 0
  15k
  30k
  zaxxon
  Number of frames 0 100M 200M
  10
  5
  0
  5
  Av g.
  e pi
  so de
  r et
  ur n
  sokoban
  1 0M 200M 0 1 0M 200M 0
  8k
  16k
  24k
  lt
  0 200M 0
  10k
  20k
  30k asteroids
  0 2 0M 0
  10k
  20k
  30k wizard
  0 10 M 200 0
  15k
  30k
  zaxxon
  u ber of fra es
  (b) Self-consistency on Sokoban and 5 Atari games. Each experiment was run with 5 independent replicas using different random seeds. The self-consistency updates were applied to variants of Muesli, a model-based RL agent using deep neural networks for function approximation and value equivalent models for planning.
  Figure 2: An evaluation of Dyna and the self-consistency updates described in section 3.1. Each variant was evaluated in both a tabular setting (a) and with function approximation (b). The experiments included both MLE and value equivalent models. Shaded regions denote 90% CI.
sections.heading: 4 Experiments
sections.heading: 4.1 Sample efficiency through self-consistency
sections.text: Tabular. In our first set of experiments, we used random “Garnet” MDPs [2] to study different combinations of grounded and self-consistent updates for approximate models and values. We followed an alternating minimization approach as described in Section 3.2. In each case, we applied the Dyna, SC-Direct, SC-Reverse, SC-Residual updates at each iteration starting at every state in the MDP. See Appendix A for further details of our experimental setup.
  Figure 2a (on the left) shows the relative value error, calculated as |(v(s)− v̂(s))/v(s)|, averaged across all states in the MDP, when evaluating a random policy. As we expected, Dyna improved the speed of value learning over a model-free baseline. We saw considerable difference among the self-consistent updates. The “residual” and “reverse” updates were ineffective and harmful, respectively. In contrast, the “direct” self-consistency update was able to accelerate learning, even compared to Dyna, for both MLE and value-equivalent models.
  Figure 2a (on the right) shows the value of the policy (normalised by the optimal value), averaged across all states, for a control experiment with the same class of MDPs. At each iteration, we construct Q̂(s, a) estimates using the model, and follow an -greedy policy with = 0.1. In this case, the variation between methods is smaller. The “direct” method still achieves the best final performance. However, the “residual” and “reverse” self-consistency updates are competitive for tabular control.
  Function approximation. We evaluated the same selection of imagination-based updates in a deep RL setting, using a variant of the Muesli [25] agent. The only difference is in the hyperparameters for batch size and replay buffer, as documented in the Appendix (this seemed to perform more stably as a baseline in some early experiments). All experiments were run using the Sebulba distributed
  architecture [26] and the joint optimization sketched in Algorithm 1. We used 5 independent replicas, with different random seeds, to assess the performance of each update.
  We evaluated the performance of the updates on a selection of Atari 2600 games [6], plus the planning environment Sokoban. In Sokoban, we omit the policy-gradient objective from the Muesli baseline because with the policy gradient, the performance ceiling for this problem is quickly reached. Using only the MPO component of the policy update relies more heavily on the model, giving us a useful testbed for our methods in this environment, but should not be regarded as state-of-the-art.
  We first evaluated a Dyna baseline, using experience sampled from the latent-space value-equivalent model. As in the tabular case, we did so by taking the gradient of the objective (7) with respect to only the parameters of the value predictor v̂. Unlike the simple tabular case, where Dyna performed well, we found this approach to consistently degrade performance at scale (Figure 2b, “Dyna”). To the best of our knowledge, this was the first attempt to perform Dyna-style planning with value-equivalent models, and it was a perhaps-surprising negative result. Note the contrast with the success reported in previous work [23] for using Dyna-style planning with MLE models on Atari.
  Next we evaluated the self-consistency updates. We found that the “residual” self-consistency update performed poorly. We conjecture that this was due to the model converging on degenerate trivially self-consistent solutions, at the cost of optimising the grounded objectives required for effective learning. The degradation in performance was even more dramatic than in the tabular setting, perhaps due to the greater flexibility provided by the use of deep function approximation.
  This hypothesis is consistent with our next finding: both semi-gradient objectives performed much better. In particular, the “direct” self-consistency objective increased sample efficiency over the baseline in all but one environment. We found the “reverse” objective to also help in multiple domains, although less consistently across the set of environments we tested. As a result, in subsequent experiments we focused on the “direct” update, and investigated whether the effectiveness of this kind of self-consistency update can be improved further.
sections.heading: 4.2 Search control for self-consistency
sections.text: Search control is the process of choosing the states and actions with which to query the model when planning [52]; we know from the literature that this can substantially influence the effectiveness of planning algorithms such as Dyna [40]. Since our self-consistency objective also allows flexibly updating the value of states that do not correspond to the states observed from real actions taken in the environment, we investigated the effect of different choices for imagination policy µ and starting states Z0. Which policy should be followed in imagination? We now explore four choices for the policy followed in imagination to generate trajectories used by the self-consistency updates. The simplest choice is to sample actions according to the same policy we use to interact with the real environment (µ = π). A second option is to pick a random action with probability , and otherwise follows π (we try =0.5). The third option is to avoid the first action that was actually taken in the environment to ensure diversity from the real behaviour. After sampling a different first action, the policy π is used to sample the rest (Avoid a0). The last option is to replay the original sequence of actions that were taken in the environment (Original actions). This corresponds to falling back to the base agent’s value loss, but with rewards and value targets computed using the model in place of the real experience.
  In Figure 3a, we compare these options. A notable finding was that just replaying exactly the actions taken in the environment (in brown) performed considerably worst than re-sampling the actions from π (in blue). This confirms our intuition that the ability to make use of arbitrary trajectories is a critical aspect of the self-consistency update. Introducing more diversity by adding noise to the policy π had little effect on most environments, although the use of = 0.5 did provide a benefit in assault and asteroids. Avoiding the first behaviour action, to ensure that only novel trajectories are generated in imagination, also performed reasonably well. Overall, as long as we generated a new trajectory by sampling from a policy, the self-consistency update was fairly robust to all the alternatives considered.
  From which states should we start imagined rollouts? A search control strategy must also prescribe how the starting states are selected. Since we use a latent-space model, we investigated using latent-space perturbations to select starting states close (but different) from those encountered in the environment. We used a simple perturbation, multiplying the latent representation z0t element-wise
  so ko
  ba n
  ali en
  as sa
  ult
  as ter
  oid s
  wi za
  rd
  za xx
  on 0.00
  0.25
  0.50
  0.75
  1.00
  1.25
  N or
  m al
  is ed
  A U
  C
  Original actions =
  =0.5 Avoid a0
  Latent noise, = Latent noise, =0.5
  (a) Different search control strategies for self-consistency. Each experiment used 5 random seeds, error bars denote 90% CI.
  0 25 50 75 100 125 150 175 200 Millions of frames
  0%
  100%
  200%
  300%
  400%
  500%
  M ed
  ia n
  hu m
  an -n
  or m
  al iz
  ed s
  co re
  LASER
  Rainbow
  atari57 median Muesli Muesli + SC
  (b) Median human-normalised episode return on across 57 Atari games. Each experiment used 4 random seeds, shaded region denote 90% CI.
  0 500 M 1 G 1.5 G 2 G 2.5 G Environment steps
  0.0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  W in
  ra te
  v s
  Pa ch i Method
  Baseline + SC
  MCTS True False
  (c) Performance on 9x9 self-play Go, with evaluation against Pachi [5] Each experiment used 5 random seeds, shaded region denote 90% CI.
  Figure 3: Search control for self consistency, and evaluations on Atari and Go.
  by noise drawn from U(0.8, 1.2) (Latent noise, µ = π). The results for these experiments are also shown in Figure 3a. The effect was not large, but the variant combining latent state perturbations with − exploration in the imagination policy (Latent noise, = 0.5) performed best amongst all variants we considered. The fact that some benefit was observed with such rudimentary data augmentation suggests that diverse starting states may be of value. Self-consistency could therefore be effective in semi-supervised settings where we have access to many valid states (e.g. reachable configurations of a robotic system), but few ground-truth rewards or transitions.
  A full evaluation. In the next experiments we evaluated our self-consistency update on the full Atari57 benchmark, with the search-control strategy found to be most effective in the previous section. As shown in Figure 3b, we observed a modest improvement over the Muesli baseline in the median human-normalised score across the 57 environments. We also evaluated the same self-consistency update in a small experiment on self-play 9x9 Go in combination with a Muesli-MPO baseline, with results shown in Figure 3c. Again, the agent using self-consistency updates outperformed the baseline, both with (solid lines) and without (dashed lines) the use of MCTS at evaluation time. This confirms that the self-consistent model is sufficiently robust to be used effectively for planning online.
sections.heading: 4.3 How does self-consistency work?
sections.text: Representation learning. In our final set of experiments we investigated how self-consistency affects the learning dynamics of our agents. First, we analysed the impact of self-consistency on the learned representation. In Figure 4a we compare (1) a policy-gradient baseline “PG” that does not use a model (2) learning a value-equivalent model purely as an auxiliary task “+VE Aux”, and (3)
  augmenting this auxiliary task with our self-consistency objective “+SC Aux”. When we configure Muesli to use the model purely as an auxiliary there is no MPO-like loss term, and the value function bootstrap uses state values rather than model-based Q values. We found that self-consistency updates were helpful, even though the model was neither used for value estimation nor policy improvement; this suggests that self-consistency may aid representation learning.
  Information flow. Self-consistency updates, unlike Dyna, move information between the reward model, transition model, and value function. To study this effect, we returned to tabular policy evaluation. We analysed the robustness of self consistency to initial additive Gaussian noise in the reward model. Figure 5 (left) shows the area under the value error curve as a function of the noise. With worse initialisation the effectiveness of the self-consistency update deteriorates more rapidly than the Dyna update, especially when learning with MLE. The reward model is learned in a grounded manner, so will receive the same updates with Dyna or SC. In the Dyna case, the poor reward initialisation can only pollute the value function. With SC, information can also flow from the impaired reward model into the dynamics model, and from there damage the value function further in turn. A different effect can be seen when varying the value initialisation by adding noise to the true value, as shown in Figure 5 (right). Since the value is updated by SC, it is possible for a poorly initialised value to be fixed more rapidly if SC is effective. Indeed, we see a slight trend towards a greater advantage for SC when value initialisation is worse. However, this is not a guarantee; certain poor initialisations could lead to self-reinforcing errors with SC, which is reflected in the overlapping confidence intervals.
  Scaling with computation. Self-consistency updates, like Dyna, allow to use additional computation without requiring further interactions in the environment. In Figure 4b, we show the effect of rolling out different numbers of imagined trajectories to estimate the self-consistency loss, by randomly choosing a fraction of the states in each batch to serve as starting points (for ratios greater than one we randomly duplicated starting states). In the domains where self-consistency was beneficial, the potential gains often increased with the sampling of additional starting-states. However, in most cases saturation was reached when one imagined trajectory was sampled for each state in the batch (ratio=1 was the default in the experiments described above).
sections.heading: 5 Related work
sections.text: Model learning can be useful to RL agents in various ways, such as: (i) aiding representation learning [46, 28, 33, 20, 25] (ii) planning for policy optimisation and/or value learning [55, 51, 21, 10]; (iii) action selection via local planning [45, 49]. See Moerland et al. [36] or Hamrick et al. [24] for a survey of how models are used in RL. Many approaches to learning the model have been investigated in the literature, usually based on the principle of maximum likelihood estimation (MLE) [32, 51, 38, 21, 31, 10, 22]. Hafner et al. [23] notably showed that a deep generative model of Atari games can be used for Dyna-style learning of a policy and value only in the imagination of the model, performing competitively with model-free methods.
  RL-informed objectives have been used in some recent approaches to learn implicit or explicit models that focus on the aspects of the environment that are relevant for control [53, 50, 39, 16, 30, 47, 18, 44, 25]. This type of model learning is connected to theoretical investigations of “value-aware” model learning [15], which discusses an equivalence of Bellman operators applied to worst-case functions from a hypothesis space; “iterative value-aware model learning” [14] which, closer to our setting, uses an equivalence of Bellman operators applied to a series of agent value-functions; and the “value equivalence” (VE) principle [19], which describes equivalences between Bellman operators applied to sets of arbitrary functions.
  All the approaches to model learning discussed above leverage observed real experience for learning a model of the environment. In contrast, our self-consistency principle provides a mechanism for model learning using imagined experience. This is related to the work of Silver et al. [50], where self-consistency updates were used to aid learning of temporally abstract models of a Markov reward process. Filos et al. [17] also used self-consistency losses, for offline multi-task inverse RL. Selfconsistency has been applied in other areas of machine learning as well. Consider, for instance, back-translation [8, 12] in natural language processing, or CycleGANs [58] in generative modelling.
  In this paper we considered models that can be rolled forward. It is also possible to consider backward models, that can be used to assign credit back in time [54, 11]. The principle of self-consistency we introduce in this work can be extended to these kinds of models fairly straightforwardly. A different type of self-consistency was studied concurrently by Yu et al. [56], who develop a model-based system where a forward and backward model are trained to be cyclically consistent with each other.
sections.heading: 6 Conclusion
sections.text: We introduced the idea of self-consistent models and values. Our approach departs from classic planning paradigms where a model is learned to be consistent with the environment, and values are learned to be consistent with the model. Amongst possible variants, we identified as particularly promising an update modelled on semi-gradient temporal difference objectives. We found this update to be effective both in tabular settings and with function approximation. Self-consistency updates proved particularly well suited to deep value-equivalent model-based agents, where traditional algorithms such as Dyna were found to perform poorly. The self-consistency objectives discusses in this paper are based on a form of policy-evaluation; future work may investigate extensions to enable value-equivalent model-based agents to perform policy improvement for states in arbitrary trajectories drawn from the model.
  Acknowledgments and Disclosure of Funding
  We would like to thank Ivo Danihelka, Junhyuk Oh, Iurii Kemaev, and Thomas Hubert for valuable discussions and comments on the manuscript. Thanks also to the developers of Jax [9] and the DeepMind Jax ecosystem [3] which were invaluable to this project. The authors received no specific funding for this work.
title: Self-Consistent Models and Values