{'fraction_non_alphanumeric': 0.042163233194440396, 'fraction_numerical': 0.016725429062618376, 'mean_word_length': 4.327538031667184, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Deep Reinforcement and InfoMax Learning

Our work is based on the hypothesis that a model-free agent whose representations are predictive of properties of future states (beyond expected rewards) will be more capable of solving and adapting to new RL problems. To test that hypothesis, we introduce an objective based on Deep InfoMax (DIM) which trains the agent to predict the future by maximizing the mutual information between its internal representation of successive timesteps. We provide an intuitive analysis of the convergence properties of our approach from the perspective of Markov chain mixing times and argue that convergence of the lower bound on mutual information is related to the inverse absolute spectral gap of the transition model. We test our approach in several synthetic settings, where it successfully learns representations that are predictive of the future. Finally, we augment C51, a strong RL baseline, with our temporal DIM objective and demonstrate improved performance on a continual learning task and on the recently introduced Procgen environment.


Introduction
In reinforcement learning (RL), model-based agents are traditionally characterized by their ability to predict future states and rewards based on previous states and actions [Sutton and Barto, 1998, Ha and Schmidhuber, 2018, Hafner et al., 2019a. Model-based methods can be seen through the representation learning [Goodfellow et al., 2017] lens as endowing the agent with internal representations that are predictive of the future conditioned on its actions. This ultimately gives the agent the ability to plan -by e.g. considering a distribution of possible future trajectories and picking the best course of action.
Model-free methods, on the other hand, do not learn an explicit model of the environment, and instead focus on learning a policy that maximizes reward or a function that estimates the optimal values of states and actions [Mnih et al., 2013, Schulman et al., 2017, Pong et al., 2018. They can use large amounts of training data and excel in high-dimensional state and action spaces. However, this is mostly true for fixed reward functions. Despite success on many benchmarks, model-free agents typically generalize poorly when the environment or reward function changes [Farebrother et al., 2018, Tachet des Combes et al., 2018 and can have high sample complexity.
Viewing model-based agents from a representation learning perspective, a desired outcome is an agent able to understand the underlying generative factors of the environment that determine the observed state/action sequences, which would help generalization to environments built from the same generative factors. In addition, learning a predictive model often involves much richer learning signals than those provided by reward alone, which could reduce sample complexity compared to model-free methods.
Our work is based on the hypothesis that a model-free agent whose representations are predictive of properties of future states (beyond expected rewards) will be more capable of solving and adapting to new RL problems, and in a way, incorporate aspects of model-based learning. To learn representations with model-like properties, we consider a self-supervised objective derived from variants of Deep InfoMax [DIM, Hjelm et al., 2018, Bachman et al., 2019, Anand et al., 2019. We expect this type of contrastive estimation [Hyvarinen and Morioka, 2016] will give the agent a better understanding of the underlying factors of the environment and how they relate to its actions, eventually leading to better performance in transfer and lifelong learning problems. We examine the properties of the learnt representations in simple domains such as disjoint and glued Markov chains, and more complex environments such as a 2d Ising model, a sequential variant of Ms. PacMan from the Atari Learning Environment [ALE, Bellemare et al., 2013], and all 16 games from the Procgen suite [Cobbe et al., 2019]. Our contributions are as follows: • We propose a simple auxiliary objective that maximizes concordance between representations of successive states, given the action.
• We present a series of experiments showing how our objective can be used as a measure of similarity and predictability, and how it behaves in partially deterministic systems.
• Finally, we show that augmenting a standard C51 agent [Bellemare et al., 2017] with our contrastive objective can i) lead to faster adaptation in a continual learning setting, and ii) improve overall performance on the Procgen suite.

Background
Just as humans are able to retain old skills when taught new ones [Wixted, 2004], we strive for RL agents that are able to adapt quickly and reuse knowledge when dealing with a sequence of different tasks with variable reward functions. The reason for this is that real-world applications or downstream tasks can be difficult to predict before deployment, particularly with complex environments involving other intelligent agents such as humans. Unfortunately, this proves to be very challenging even for state-of-the-art systems [Atkinson et al., 2018], leading to complex deployment scenarios.
Continual Learning (CL) is a learning framework meant to benchmark an agent's ability to adapt to new tasks by using auxiliary information about the relatedness across tasks and timescales [Kaplanis et al., 2018, Mankowitz et al., 2018. Meta-learning [Thrun andPratt, 1998, Finn et al., 2017] and multi-task learning [Hessel et al., 2019, D'Eramo et al., 2019 have shown good performance in CL by explicitly training the agent to transfer well between tasks.
In this study, we focus on the following inductive bias: while the reward function may change or vary, the underlying environment dynamics typically do not change as much 2 . To test if that inductive bias is useful, we use auxiliary loss functions to encourage the agent to learn about the underlying generative factors and their associated dynamics in the environment, which can result in better sample efficiency and transfer capabilities (compared to learning from rewards only). Previous work has shown this idea to be useful when training RL agents: e.g., Jaderberg et al. [2016] train the agent to predict future states given the current state-action pair, while Mohamed and Rezende [2015] uses empowerment to measure concordance between a sequence of future actions and the end state. Recent work such as DeepMDP [Gelada et al., 2019] uses a latent variable model to represent transition and reward functions in a high-dimensional abstract space. In model-based RL, various agents, such as PlaNet [Hafner et al., 2019b], Dreamer [Hafner et al., 2019a] or MuZero [Schrittwieser et al., 2019], have also shown strong asymptotic performance.
Contrastive representation learning methods are based on training an encoder to capture information that is shared across different views of the data in the features it produces for each input. The similar (i.e. positive) examples are typically either taken from different "locations" of the data [e.g., spatial patches or temporal locations, see Hjelm et al., 2018, Oord et al., 2018, Anand et al., 2019, Hénaff et al., 2019 or obtained through data augmentation [Wu et al., 2018, He et al., 2019, Bachman et al., 2019, Tian et al., 2019, Chen et al., 2020. Contrastive models rely on a variety of objectives to encourage similarity between features. Typically, a scoring function [e.g., dot product or cosine similarity between pairs of features, see Wu et al., 2018] that lower-bounds mutual information is maximized [Belghazi et al., 2018, Hjelm et al., 2018, Oord et al., 2018, Poole et al., 2019. In an RL setting, Oord et al. [2018] augment an A2C agent with a contrastive objective at different timesteps which improves performance on 5 DeepMind lab games [Beattie et al., 2016]. CURL [Srinivas et al., 2020] uses a contrastive objective between augmented versions of the current timestep. Finally, EMI [Kim et al., 2019] uses a Jensen-Shannon divergence based lower bound on mutual information to form an exploration bonus. In comparison, our work focuses on the predictability of future states based on the current state-action pair at multiple scales [Bachman et al., 2019] in the encoder.

Markov Chains
Given a discrete state space S with probability measure T, a discrete-time homogeneous Markov chain (MC) is a collection of random variables with the following property on its transition matrix T ∈ R |S|×|S| : T ss ′ = P[S t+1 = s ′ |S t = s], ∀s, s ′ ∈ S, ∀t ≥ 0. Assuming the Markov chain is ergodic, its invariant distribution 3 ρ is the principal eigenvector of T, which verifies ρT = ρ and summarizes the long-term behaviour of the chain. We define the marginal distribution of S t as p t (s) := P[S t = s] = T t s: , and the initial distribution of S as p 0 (s).

Markov Decision Processes
A discrete-time, finite-horizon Markov Decision Process [Bellman, 1957, Puterman, 2014, MDP] comprises a state space S, an action space 4 A, a transition kernel T : S × A × S → [0, 1], a reward function r : S × A → R and a discount factor γ ∈ [0, 1]. At every timestep t, an agent interacting with this MDP observes the current state s t ∈ S, selects an action a t ∈ A, and observes a reward r(s t , a t ) ∈ R upon transitioning to a new state s t+1 ∼ T (s t , a t , ·). The goal of an agent in a discounted MDP is to learn a policy π : S × A → [0, 1] such that taking actions a t ∼ π(s t , ·) maximizes the expected sum of discounted returns, To convert a MDP into a MC, one can let T π ss ′ = E a∼π(s,·) [T (s, a, s ′ )], an operation which can be easily tensorized for computational efficiency in small state spaces [see Mazoure et al., 2020].
For this paper, we use the C51 algorithm [Bellemare et al., 2017] for training the agent due to its simplicity and good performance on control tasks from pixels. C51 minimizes the following loss: where D KL is the Kullback-Leibler divergence, Z(s, a) is the distribution of discounted returns (s.t. E[Z(s, a)] = Q(s, a)), T is the distributional Bellman operator [Bellemare et al., 2019] and ⌊·⌋ 51 is an operator which projects Z onto a fixed support of 51 atoms.

State-action mutual information maximization
Mutual information (MI) measures the amount of information shared between a pair of random variables and can be estimated using neural networks [Belghazi et al., 2018]. Recent representation learning algorithms [Oord et al., 2018, Hjelm et al., 2018, Hénaff et al., 2019, Tian et al., 2019, He et al., 2019 train encoders to maximize MI between features taken from different views of the input -e.g., different patches in an image or different versions of an image produced by applying data augmentation. These algorithms commonly optimize lower bounds on the MI based on noisecontrastive estimation [NCE, Gutmann andHyvärinen, 2010, Oord et al., 2018].
Let k be some fixed temporal offset. Running a policy π in the MDP M generates a distribution over tuples (s t , a t , s t+k ), where s t corresponds to the state of M at some timestep t, a t to the action selected by π in state s t and s t+k to the state of M at timestep t + k, reached by following π. We let S t , A t and S t+k denote the corresponding random variables. We denote the joint distribution of these variables and their associated marginals using p. We consider maximizing the MI between state-action pairs (S t , A t ) and their future states S t+k , which can be written as follows: Estimating the MI amounts to training a classifier that discriminates between a sample (s t , a t , s t+k ) drawn from the joint distribution and a sample from the product of marginals in the denominator of Eq. 3. A sample from the product of marginals can be obtained by replacing s t+k (we call this the positive sample) with a state picked at random from another trajectory (we call this a negative sample). Letting S − denote a set of such negative samples, the infoNCE loss function [Oord et al., 2018] that we use to maximize a lower bound on the MI in Eq. 3 takes the following form: where Ψ(s, a), Φ(s) are features that depend on state-action pairs and states, respectively, and φ is a function that outputs a scalar-valued score. Minimizing L N CE with respect to Φ, Ψ, and φ maximizes the MI between these features. In practice, we construct S − by including all statess t+k from other tuples (s t ,ã t ,s t+k ) in the same minibatch as the relevant (s t , a t , s t+k ). I.e., for a batch containing N tuples (s t , a t , s t+k ), each S − would contain N − 1 negative samples.

Architecture and Algorithm
We now specify forms for the functions Φ, Ψ, and φ. We consider a deep neural network Θ : S → 5 i=1 F i which maps input states onto a sequence of progressively more "global" (or less "local") feature spaces. In practice, Θ is a deep residual and CNN composed of functions that sequentially map inputs to features {f i ∈ F i } 1≤i≤5 (lower to upper "levels" of the network).
The features f 5 are the output of the network's last layer and correspond to the standard C51 value heads (i.e., they span a space of 51 atoms per action) 5 . For the auxiliary objective, we follow a variant of Deep InfoMax [DIM, Hjelm et al., 2018, Anand et al., 2019, Bachman et al., 2019, and train the encoder to maximize the mutual information (MI) between local and global "views" of tuples (s t , a t , s t+k ). The local and global views are realized by selecting f 3 ∈ F 3 and f 4 ∈ F 4 respectively. In order to simultaneously estimate and maximize the MI, we embed the action (represented as a one-hot vector) using a function Ψ a : A →Ã. We then map the local states f 3 and the embedded action using a function Ψ 3 : F 3 ×Ã → L, and do the same with the global states f 4 , i.e., Ψ 4 : F 4 ×Ã → G. In addition, we have two more functions, Φ 3 : F 3 → L and Φ 4 : F 4 → G that map features without the actions, which will be applied to features from "future" timesteps. Note that L can be thought of as a product of local spaces (corresponding to different patches in the input, or equivalently different receptive fields), each with the same dimensionality as G.
We use the outputs of these functions to produce a scalar-valued score between any combination of local and global representations of state s t and s t+k , conditioned on action a t : 5 Θ can equivalently be seen as the network used in a standard C51.
In practice, for the functions that take features and actions as input, we simply concatenate the values at position f 3 (local) or f 4 (global) with the embedded action Ψ a (a), and feed the resulting tensor into the appropriate function Ψ 3 or Ψ 4 . All functions that process global and local features are computed using 1 × 1 convolutions. See Figure 4 for a visual representation of our model.
We use the scores from Eq. 5 when computing the infoNCE loss [Oord et al., 2018] for our objective, using (s t , a t , s t+k ) tuples sampled from trajectories stored in an experience replay buffer: .
Combining Eq. 6 with the C51 update in Eq. 2 yields our full training objective, which we call DRIML 6 . We optimize Θ, Ψ 3,4,a , and Φ 3,4 jointly using a single loss function: Note that, in practice, the compute cost which Eq. 7 adds to the core C51 RL algorithm is minimal, since it only requires additional passes through the (small) state/action embedding functions followed by an outer product.
Compute L N tM DIM using Eq. 6 (see Appendix 8.3 for PyTorch code); Update Θ, Ψ 3,4,a , and Φ 3,4 using gradients of λ N tM L N tM DIM ; end end end The proposed Algorithm 1 introduces an auxiliary loss which improves predictive capabilities of value-based agents by boosting similarity of representations close in time.

Predictability and Contrastive Learning
Information maximization has long been considered one of the standard principles for measuring correlation and performing feature selection [Song et al., 2012]. In the MDP context, high values 6 Deep Reinforcement and InfoMax Learning of I([S t , A t ], S t+k ) indicate that (S t , A t ) and S t+k have some form of dependence, while low values suggest independence. The fact that predictability (or more precisely determinism) in Markov systems is linked to the MI suggests a deeper connection to the spectrum of the transition kernel T . For instance, the set of eigenvalues of T for a Markov decision process contains important information about the connectivity of said process, such as mixing time or number of densely connected clusters [Von Luxburg, 2007, Levin andPeres, 2017].
Consider the setting in which π is fixed at some iteration in the optimization process. In the rest of this section, we let T denote the expected transition model T(s, pt+1(s ′ ) be the ratio learnt when optimizing the infoNCE loss on samples drawn from the random variables S t and S t+1 (for a fixed t) [Oord et al., 2018]. We also let ν ∞ (s, s ′ ) = T(s,s ′ ) ρ(s ′ ) be that ratio when the Markov chain has reached its stationary distribution ρ (see Section 3.1), andν t (s, s ′ ) be the scoring function learnt using InfoNCE (which converges to ν t (s, s ′ ) in the limit of infinite samples drawn from (S t , S t+1 )).
Proposition 1 Let 0 < ǫ ≤ 1. Assume at time step t, training ofν t has close to converged on a pair (s, s ′ ), i.e. |ν t (s, s ′ ) −ν t (s, s ′ )| < ǫ. Then the following holds: The proof can be found in App. 8.4. Proposition 1 combined with Theorem 3.1 suggests that faster convergence ofν t to ν ∞ happens when the spectral gap 1 − λ (2) of T is large, or equivalently when λ (2) is small. It follows that, on one hand, mutual information is a natural measure of concordance of (s, s ′ ) pairs and can be maximized using data-efficient, batched gradient methods. On the other hand, the rate at which the InfoNCE loss converges to its stationary value (ie maximizes the lower bound on MI) depends on the spectral gap of T , which is closely linked to predictability (see Appendix 8.2).

Experiments
In this section, we first show how our proposed objective can be used to estimate state similarity in single Markov chains. We then show that DRIML can capture dynamics in locally deterministic systems (Ising model), which is useful in domains with partially deterministic transitions. We then provide results on a continual version of the Ms.PacMan game where the DIM loss is shown to converge faster for more deterministic tasks, and to help in a continual learning setting. Finally, we provide results on Procgen [Cobbe et al., 2019], which show that DRIML performs well when trained on 500 fixed levels. All experimental details can be found in App. 8.5.

DIM learns a transition ratio model
We first study the behaviour of contrastive losses on a simple Markov chain describing a biased random walk in {1, · · · , K}. The bias is specified by a single parameter α. The agent starting at state i transitions to i + 1 with probability α and to i − 1 otherwise. The agent stays in states 1 and K with probability 1 − α and α, respectively. We encode the current and next states (represented as one-hots) using a 1-hidden layer MLP 7 (corresponding to Ψ and Φ in equation 4), and then optimize the NCE loss L DIM (4) (the scoring function φ is also 1-hidden layer MLP) to maximize the MI between representations of successive states. Results are shown in Fig. 2b, they are well aligned with the true transition matrix (Fig. 2c).
The spectral gap of the transition matrix can be computed in closed-form as a function of α. Its lowest value is reached in the neighbourhood α = 0.5, corresponding to the point where the system is least predictable (as shown by the mutual information, Fig 2c). Derivations are available in Appx 8.5.1. 7 The action is simply ignored in this setting. 6.2 DIM can capture complex partially deterministic dynamics The goal of this experiment is to highlight the predictive capabilities of our DIM objective in a partially deterministic system. We consider a dynamical system composed of N × N pixels with values in {−1, 1}, At the beginning of each episode, a patch corresponding to a quarter of the pixels is chosen at random in the grid. Pixels that do not belong to that patch evolve fully independently (p(s ij (t) = 1 | S(t − 1)) = p(s ij (t) = 1) = 0.5). Pixels from the patch obey a local dependence law, in the form of a standard Ising model 8 : the value of a pixel at time t only depends on the value of its neighbors at time t − 1. This local dependence is obtained through a function f : ) (see Appx 8.6.1 for details). Figure 3 shows the system at t = 32 during three different episodes (black pixels correspond to values of −1, white to 1). The patches are very distinct from the noise. We then train a convolutional encoder using our DIM objective on local "views" only (see Section 4).  Figure 3 shows the similarity scores between the local features of states at t = 2 and the same features at t = 3 (a local feature corresponds to a specific location in the convolutional maps) 9 . The heatmap regions containing the Ising model (larger-scale patterns) have higher scores than the noisy portions of the lattice. Local DIM is able to correctly encode regions of high temporal predictability.

A Continual Learning experiment on Ms.PacMan
We further complicate the task of the Ising model prediction by building on top of the Ms. PacMan game and introducing non-trivial dynamics. The environment is shown in Figure 4a.
In order to assess how well our auxiliary objective captures predictability in this MDP, we define its dynamics such that P[Ghost i takes a random move] = ε. Intuitively, as ε → 1, the enemies' actions become less predictable, which in turn hinders the convergence rate of the contrastive loss. The four runs in Figure 4b correspond to various values of ε. We trained the agent using our L DRIML objective. We can see that the convergence of the auxiliary loss becomes slower with growing ε, as the model struggles to predict s t+1 given (s t , a t ). After 100k frames, the NCE objective allows to separate the four MDPs according to their principal source of randomness (red and blue curves). When ε is close to 1, the auxiliary loss has a harder time finding features that predict the next state, and eventually ignores the random movements of enemies.
The second and more interesting setup we consider consists in making only one out of 4 enemies lethal, and changing which one every 5k episodes. Figure 4c shows that, as training progresses, C51 always reaches the same performance at the end of the 5k episodes, while DRIML's steadily increases. C51 learns to ignore the harmless ghosts (they have no connection to the reward signal) and has to learn the task from scratch every time the lethal ghost changes. On the other hand, DRIML is incentivized to encode information about all the predictable objects on the screen (including the harmless ghosts), and as such adapts faster and faster to changes.   Table 1; bold values indicate best performance. Similarly to CURL, we used data augmentation on inputs to DRIML to improve the model's predictive capabilities in fast-paced environments (see App. 8.6.3). While we used the global-global loss in DRIML's objective, we have found that the local-local loss also had a beneficial effect on performance on a smaller set of games (e.g. starpilot, which has few moving entities on a dark background).

Discussion
In this paper, we introduced an auxiliary objective called Deep Reinforcement and InfoMax Learning (DRIML), which is based on maximizing concordance of state-action pairs with future states (at the representation level). Our objective has a close connection with the spectrum of the Markov transition matrix and predictability of Markovian systems, which dictate its long-term behaviour. We presented results showing that 1) DRIML implicitly learns a transition model by boosting state similarity, 2) it improves C51 in a continual learning setting and 3) it boosts training performance in complex domains such as Procgen.

Broader Impact
This work proposes an auxiliary objective for model-free reinforcement learning agents. The objective shows improvements in a continual learning setting, as well as on average training rewards for a suite of complex video games. While the objective is developed in a visual setting, maximizing mutual information between features is a method that can be transported to other domains, such as text. Potential applications of deep reinforcement learning are (among others) healthcare, dialog systems, crop management, robotics, etc. Developing methods that are more robust to changes in the environment, and/or perform better in a continual learning setting can lead to improvements in those various applications. At the same time, our method fundamentally relies on deep learning tools and architectures, which are hard to interpret and prone to failures yet to be perfectly understood. Additionally, deep reinforcement learning also lacks formal performance guarantees, and so do deep reinforcement learning agents. Overall, it is essential to design failsafes when deploying such agents (including ours) in the real world. 8 Appendix

Link to invariant distribution
For a discrete state ergodic Markov chain specified by P and initial occupancy vector p 0 , its marginal state distribution at time t is given by the Chapman-Kolmogorov form: and its limiting distribution σ is the infinite-time marginal which, if it exists, is exactly equal to the invariant distribution ρ.
For the very restricted family of ergodic MDPs under fixed policy π, we can assume that p t converges to a time invariant distribution ρ. Therefore, Now, observe that I t is closely linked to T /ρ when samples come from timesteps close to t mix (ε).
That is, interchanging swapping ρ(s) and p t (s) at any state s would yield at most δ(t) error. Moreover, existing results [Levin and Peres, 2017] from Markov chain theory provide bounds on ||(P t+1 ) s: − (P t ) s: || T V depending on the structure of the transition matrix.
If P has a limiting distribution σ, then using the dominated convergence theorem allows to replace matrix powers by σ, which is then replaced by the invariant distribution ρ: Of course, most real-life Markov decision processes do not actually have an invariant distribution since they have absorbing (or terminal) states. In this case, as the agent interacts with the environment, the DIM estimate of MI yields a rate of convergence which can be estimated based on the spectrum of P.
Moreover, one could argue that since, in practice, we use off-policy algorithms for this sort of task, the gradient signal comes from various timesteps within the experience replay, which drives the model to learn features that are consistently predictive through time.

Predictability and spectrum of an MDP
In the simplest case of a discrete MDP, T fully describes the dynamics of the environment. The row T sa: corresponds to the probability of landing in any state s ′ by taking action a from state s. Since a perfectly deterministic environment would transition to exactly one state with probability 1, an agent equipped with T will know exactly what s ′ would look like and adjust its planning accordingly. Simply speaking, in a predictable Markov environment, the values of the random vector [S t , A t ] should be maximally correlated with those of S t+1 .
As seen in the main paper, dependence of S t+k on (S t , A t ), k, t > 0 can be explicitly encouraged by boosting the mutual information of the coupling. How effective the model is at solving this optimization problem depends mostly on the topology of the system: estimating the AMI for a timehomogeneous, ergodic MDP turns out to be quite easy, as shown in the experiments section. The rate of convergence of the InfoNCE bound to true AMI depends mostly on the inverse spectral gap of the transition kernel. More generally, if we think of T as inducing a transition graph G with the following rule: then the spectral gap is related to the Cheeger constant of G. For instance, if T is allowed to transition from any state to any other state, the corresponding graph would be fully connected, while having a deterministic transition (s, a) → s ′ would make the graph a maximal directed pseudoforest. In summary, if one has access to the spectral gap of an MC, they can roughly estimate the connectedness of the system: the sparser the graph, the easier the search problem.
The spectrum of P π is trivial to estimate in the tabular case; for the large-dimensional case, one can use the variational power method [Wen et al., 2020, VPM] by applying Hotteling's deflation: 1. Using (s, s ′ ) samples from P π , find principal eigenfunction ρ 1 via VPM; 2. The corresponding eigenvalue should be close to λ ≈ 1 and found as ρ ⊤ Pπ ρ ρ ⊤ ρ ; 3. Use rejection sampling on the same dataset as in 1. to form a new dataset s.t.
In our experiments, we managed to exactly estimate the spectral gap for tabular Markov chains, a task that is more complicated for large-dimensional inputs (e.g. pixels) since the transition model is typically parameterized by a neural network.

Code snippet for DIM objective scores
The following snippet yields pointwise (i.e. not contracted) scores given a batch of data. 1 def temporal_DIM_scores(reference,positive,clip_val=20):  To obtain a scalar out of this batch, sum over the third dimension and then average over the first two.

Proof of Proposition 1
For a given timestep t > 0 and a pair (s, s ′ ), let ν t (s, s ′ ) = T(s,s ′ ) pt+1(s ′ ) be the true ratio at time t and let ν ∞ (s, s ′ ) = T(s,s ′ ) ρ(s ′ ) be the true ratio when the Markov chain has reached its stationary state. Letν t (s, s ′ ) be a function we train using the infoNCE loss on samples drawn from the random variables S t and S t+1 (for a fixed t).

Experiment details
All experiments involving RGB inputs (Ising, Ms.PacMan and Procgen) were ran with the settings shown in Table 2. The global DIM heads consist of a standard single hidden fully-connected layer network of 512 with ReLU activations and a skip-connection from input to output layers. The action is transformed into one-hot and then encoded using a 64 unit layer, after which it is concatenated with the state and passed to the global DIM head.
The local DIM heads consist of a single hidden layer network made of 1 × 1 convolution. The action is tiled to match the shape of the convolutions, encoded using a 1 × 1 convolutions and concatenated along the feature dimension with the state, after which is is passed to the local DIM head.
In the case of the Ising model, there is no decision component and hence no concatenation is required.

AMI of a biased random walk
We see from the formulation of the mutual information objective I(S t+1 , S t ) that it inherently depends on the ratio of P/ρ. Recall that, for a 1-d random walk on integers [0, N ), the stationary distribution is a function of α 1−α and can be found using the recursion P[S for r = α 1−α . The pointwise mutual information between states S t and S t+1 is therefore the random variablė with expectation equal to the average mutual information which we can find by maximizing, among others, the InfoNCE bound. We can then compute the AMI as a function of α which is shown in Figure 2c.
The figures were obtained by training the global DIM objective Φ 4 on samples from the chain for 1,000 epochs with learning rate 10 −3 .
At every timestep, we uniformly sample a random index tuple (i, j), 21 ≤ i, j ≤ 63 and evolve the set of nodes v = {v k,l : i − 21 ≤ k ≤ i + 21, j − 21 ≤ l ≤ j + 21} according to an Ising model with temperature β −1 = 0.4, while the remaining nodes continue to independently take the values {−1, 1} with equal probability. If one examines any subset of nodes outside of v, then the information conserved across timesteps would be close to 0, due to observations being independent in time.
However, examining a subset of v at timestep t allows models based on mutual information maximization to predict the configuration of the system at t + 1, since this region has high mutual information across time due to the ratio T(v,v ′ ) pt+1(v ′ ) being directly proportional to the temperature parameter β −1 .
To obtain the figure, we trained local DIM Φ 3 on sample snapshots of the Ising model as 84 × 84 grayscale images for 10 epochs. The local DIM scores were obtained by feeding a snapshot of the Ising model at t = 3; showing it snapshots from later timestep would've made the task much easier since there would be a clear difference in granularities of the random pattern and Ising models.

Ms.PacMan
In PacMan, the agent, represented by a yellow square, must collect food pellets while avoiding four harmful ghosts. When the agent collects one of the boosts, it becomes invincible for 10 steps, allowing it to destroy the enemies without dying. In their turn, ghosts alternate between three behaviours: 1) when the agent is not within line-of-sight, wander randomly, 2) when the agent is visible and does not have a boost, follow them and 3) when the agent is visible and has a boost, avoid them.
The switch between these three modes happens stochastically and quasi-independently for all four ghosts. Since the food and boost pellets are fixed at the beginning of each episode, randomness in the MDP comes from the ghosts as well as the agent's actions.
The setup for our first experiment in the domain is as follows: with a fixed probability ε, each of the 4 enemies take a random action instead of following one of the three movement patterns.
The setup for our second experiment in the domain consists of four levels: in each level, only one out of the four ghosts is lethal -the remaining three behave the same but do not cause damage. The model trains for 5,000 episodes on level 1, then switches to level 3, then level 3 and so forth. This specific environment tests for the ability of DIM to quickly figure out which of the four enemies is the lethal one and ignore the remaining three based on color .
For our study, the state space consisted of 21 × 19 × 3 RGB images. The inputs to the model were states re-scaled to 42 × 38 × 12 by stacking 4 consecutive frames, which were then concatenated with actions using an embedding layer.