Geometric Entropic Exploration

Exploration is essential for solving complex Reinforcement Learning (RL) tasks. Maximum State-Visitation Entropy (MSVE) formulates the exploration problem as a well-defined policy optimization problem whose solution aims at visiting all states as uniformly as possible. This is in contrast to standard uncertainty-based approaches where exploration is transient and eventually vanishes. However, existing approaches to MSVE are theoretically justified only for discrete state-spaces as they are oblivious to the geometry of continuous domains. We address this challenge by introducing Geometric Entropy Maximisation (GEM), a new algorithm that maximises the geometry-aware Shannon entropy of state-visits in both discrete and continuous domains. Our key theoretical contribution is casting geometry-aware MSVE exploration as a tractable problem of optimising a simple and novel noise-contrastive objective function. In our experiments, we show the efficiency of GEM in solving several RL problems with sparse rewards, compared against other deep RL exploration approaches.


Introduction
Exploration is fundamental for reinforcement learning (RL) [Sutton and Barto, 1998] agents to discover new rewarding states and ultimately find an optimal policy. In tabular settings, there exist provably efficient exploration methods based on the idea of giving reward bonuses to less explored or novel states (optimism in the face of uncertainty) [Kearns et al., 2002, Brafman and Tennenholtz, 2002, Kakade et al., 2003, Strehl et al., 2006, Lattimore and Hutter, 2014, Dann and Brunskill, 2015, Azar et al., 2017, Cohen et al., 2020, Tarbouriech et al., 2019). In practice, scaling these methods beyond small, tabular settings requires using function approximators for estimating uncertainty [Bellemare et al., 2016, Osband et al., 2016, Ostrovski et al., 2017, Pathak et al., 2017, Osband et al., 2018, Burda et al., 2018. As these uncertainty estimates are non-stationary and vanishing, this requires careful tweaking of the learning process to remain stable while allowing the policies produced by the RL algorithm to adequately explore the environment before the novelty incentive vanishes.
One way to address this issue is to learn a single stochastic policy that visits all states as uniformly as possible, which corresponds to solving the Maximum State-Visitation Entropy (MSVE) [Hazan et al., 2018, de Farias and Van Roy, 2003, Lee et al., 2019 exploration problem. In contrast to methods with vanishing bonuses that eventually stop exploring, the MSVE approach results in a stationary optimisation setup that converges to a single, stochastic exploration policy that follows different paths in different episodes, in order to cover the entire state space.
Past approaches on MSVE have been theoretically justified for discrete state spaces, as they try to maximise the discrete Shannon entropy of the state-visitation dis-arXiv:2101.02055v2 [cs.LG] 7 Jan 2021 tribution [Hazan et al., 2018, de Farias and Van Roy, 2003, Lee et al., 2019, Pong et al., 2019. While some practical approaches can be empirically applied to continuous state spaces by using density estimation techniques [Lee et al., 2019, Pong et al., 2019, their theory is still focused on discrete entropy; they do not take into account the underlying geometry implied by their density estimator. To bridge this gap, we build upon the Geometry-Aware Information Theory (GAIT) framework [Gallego-Posada et al., 2019], which relies on a similarity function k(x, x ) between states to capture the underlying geometry. Then, a geometry-aware version of Shannon entropy can be defined in terms of k that works across both discrete and continuous distributions. Ideally one would like to learn a similarity function that captures the specific geometry/structure of the problem domain.
To learn a geometry-aware exploration policy, one may directly try to maximise the geometry-aware Shannon entropy of the state-visitation distribution w.r.t. both the policy and similarity function k. However this direct approach may not succeed due to the following challenges: (i) Learning collapse. The similarity function k will ignore the geometry of the problem and collapse to an indicator function for the sake of increasing entropy, and thus is ill-defined for continuous domains. (ii) Intractability. Even with a fixed k, obtaining an unbiased estimate of this objective (or its gradients) is intractable in its original form.
In this paper we address these challenges by introducing Geometric Entropy Maximisation (GEM), a novel exploration algorithm for learning a policy that maximises the geometry-aware Shannon entropy of statevisits for a given similarity k. GEM casts the geometryaware MSVE exploration problem as a tractable noisecontrastive estimation (NCE) problem [Gutmann and Hyvärinen, 2010], via optimising a single objective function whose unbiased gradient estimates are easily computed. Maximising the GEM objective results in simultaneously learning both the optimal exploration policy and its corresponding state-visitation distribution. We also address the problem of collapse in learning the similarity function by adding an Adjacency Regularisation (AR) term which allows GEM to learn a geometrically meaningful similarity function k. GEM with AR follows two general principles: states that are close in time should be embedded closely (and be similar), whereas states that are sampled independently from the statevisitation distribution should be embedded apart (and be dissimilar). Finally, in our experiments, we show the efficiency of GEM in solving several discrete and continuous RL problems with sparse rewards, compared against other deep RL exploration approaches, namely Random Network Distillation (RND) [Burda et al., 2018] and Never Give Up (NGU) [Badia et al., 2020b].

Background
Markov Decision Processes (MDPs) and Reinforcement Learning. MDPs model stochastic, discrete-time and finite action space control problems [Bellman and Kalaba, 1965, Bertsekas, 1995, Puterman, 1994]. An MDP is a tuple (X , A, R, P, γ, T ) where X is the state space, A the action space, R the reward function, γ ∈ (0, 1) the discount factor, T the length of the episode, and P a stochastic kernel modelling the one-step Markovian dynamics, with P (y|x, a) denoting the probability of transitioning to state y by choosing action a in state x; P is also assumed to comprise a distribution for the initial state of the MDP.
A stochastic policy π maps each state and time to a distribution over actions π(·|x, t) and gives the probability π(a|x, t) of choosing action a in state x at time t. The RL objective is to maximise the expected discounted sum of rewards: E π T t=1 γ t−1 r t where r t = R(x t , a t ) and E π is the expectation over the distribution of trajectories (x 1 , a 1 , . . . , x T +1 ) from policy π.
Deep RL uses deep neural networks as function approximators [Mnih et al., 2015, 2016, Espeholt et al., 2018, Lillicrap et al., 2015. One class of such methods are policy gradient methods [Williams, 1992, Espeholt et al., 2018, which we build on to do MSVE exploration. In its simplest formulation, a deep policy gradient method learns a neural network policy π θ with parameters θ, by doing gradient ascent on the RL objective with respect to θ [Sutton et al., 1999].
Geometry-Aware Shannon Entropy. Given a state space X , we endow an underlying geometry by defining a symmetric similarity function k : X × X → [0, 1], where k(x, x ) = 1 means identity and k(x, x ) = 0 means full dissimilarity. Then given a probability distribution p(x) over X , we define its similarity pro- Then the Geometry-Aware Shannon Entropy of p with similarity k is defined as [Gallego-Posada et al., 2019]: If X is discrete, and k(x, x ) = 1(x = x ), then the similarity profile reduces to p k (x) = p(x) and we recover the standard Shannon entropy: However note that in general, with a suitable similarity function, the maximum geometry-aware Shannon entropy distribution can look very different from standard maximum Shannon entropy, as the similarity function is able to decide which states to cluster together and which states to be far apart, resulting in a uniform distribution over space (induced by the similarity) rather than over discrete points.

GEM Approach
We want to solve the geometry-aware MSVE exploration problem. Specifically, we consider finding an exploration policy π E that maximises the geometryaware Shannon entropy of its stationary state-visitation distribution: where p π (x) 1 T T t=1 p π t (x) and p π t (x) is the probability that the MDP will be in state x at timestep t when following π. In general, the solution to this optimisation problem is a stochastic policy that, over many episodes, ends up visiting as many different states as uniformly as possible.
To learn the optimal geometry-aware exploration policy π E one may choose to directly optimise the objective function H k (p π ) which is a well-defined and differentiable function of π. However the problem of maximising this objective is a challenging optimisation problem. At a high level, this is due to the fact that obtaining an unbiased estimate of the gradient of H k (p π ) is not possible in the standard direct way due to having an expectation inside the non-linear logarithmic term ln E x ∼p π [k(x, x )].
A common approach to deal with this type of intractability is to use alternating optimisation, in which as a sub-routine for Eq. 2 the learner first tries to approximate the term E x ∼p π [k(x, x )] and then uses it to maximise an estimate of H k (p π ) w.r.t. π. These alternating methods have been used for solving the Shannon-entropy MSVE as the objective [Lee et al., 2019, Pong et al., 2019. Unfortunately, the alternating approaches cannot eliminate the problem of bias in the estimate of objective function, and often are prone to instability and slow convergence [Bojanowski et al., 2017, Goodfellow, 2016, Nemirovski, 2004.
We tackle the issue of MSVE in a novel way, by defining a different, but closely related objective function whose solution also results in a geometric-aware MSVE policy, and whose unbiased gradient can be easily estimated from data. Proofs are in Appendix A.

From NCE to MSVE Exploration
The idea behind GEM can be traced back to Noise-Contrastive Estimation (NCE) [Gutmann and Hyväri-nen, 2010]. The core idea of NCE is to learn to differentiate between two distributions p + and p − . By optimising the contrastive loss, we can learn the ratio of probabilities p + /p − .
In GEM, we extend NCE to the joint estimation and optimisation of the entropy of the state-visitation distribution. We begin our derivation of the full GEM objective by first introducing a simplified special case corresponding to finite, discrete state spaces. For h : X × X → (0, ∞), consider the following objective: Maximising this objective function can be seen as contrasting positive pairs (x, x) from negative pairs  Wu et al. [2018], is its relation to the MSVE Shannon entropy: Proposition 3.0.1. Given a discrete set of states X and a function h : X × X → [0, ∞), we have max h,π GEM(h, π) = H(p π E ). The maximiser h (x, x ) = 1(x = x )/p π E (x) when p π E (x) > 0, and π E is the Shannon MSVE policy.
As a result, maximising the GEM objective over π and h simultaneously learns both the optimal state-visitation distribution and the MSVE policy as part of a single optimisation procedure.
This simple variant of GEM can be seen as a special case of M-estimation of KL-divergence through Legendre-Fenchel transformation (i.e., convex conjugate) [Nguyen et al., 2010], by using the following equivalency between KL-divergence and Shannon Entropy: where Q(x, x ) 1(x = x)p π (x) and R(x, x ) p π (x)p π (x ). Thus the theoretical results of [Nguyen et al., 2010] can be used directly to prove Proposition 3.0.1.
To make progress towards our general geometry-aware objective, we note that the optimal h (x, x ) vanishes for x = x . Therefore we introduce a new function g : X → (0, ∞) and re-parameterise h(x, x ) = 1(x = x )g(x). The objective function of Eq. 3 can then be expressed in terms of g as and we can adapt the result from Proposition 3.0.1 in following corollary: In the next section, we extend Eq. 4 to handle the general case of geometry-aware Shannon entropy.

GEM with Similarity Functions
The formulation of GEM in Eq. 4 is not, as-is, suitable for continuous state-spaces. The indicator function in the term E x,x ∼p π [1(x = x )g(x)] becomes ill-defined and the objective breaks down. To generalise GEM to continuous state-spaces, we replace the indicator function 1(x = x ) with a symmetric similarity function can then be replaced by the similarity profile p π k (x) E x ∼p π [k(x, x )], with induced geometry-aware Shannon entropy H k (p π ) Gallego-Posada et al. [2019]. The similarity function k will ideally capture the inherent structure of the state space, leading to a geometrically meaningful entropy. This can result in more efficient exploration with a suitable similarity function that ends up clustering together less important states, and thus a maximum geometryaware policy would not visit those less important states as often as other, more important states.
We now introduce the full, geometry-aware form of the GEM objective function: We generalise Corollary 3.0.1 to encompass similarity functions in Theorem 3.1.
Theorem 3.1. Let g : X → (0, ∞). Given a similarity function k : X × X → [0, 1]. Then we have max g,π GEM k (g, π) = H k (p π E ), where the maximiser is By replacing the indicator function with the similarity function k, the GEM objective generalises from discrete Shannon entropy to geometry-aware Shannon entropy, and the maximiser g generalises from the inverse probability to the inverse similarity profile. GEM can now be readily applied to both discrete and continuous state spaces.
Compared to the intractable problem of directly maximising for the geometric-aware MSVE policy, an unbiased estimate of the gradients of GEM is easily computable, and thus GEM can be solved efficiently with standard optimisers. The following theoretical result formalises this argument for the case that we parameterise π and g with some function approximatiors. Proposition 3.1.1. Let π and g be approximated by some differentiable function approximators with sets of parameters θ and ξ respectively. Let r GEM , where x t is drawn independently from p π at every time step t. Then unbiased estimates of the gradient of GEM objective w.r.t. θ and ξ are, respectively, There are a few notable remarks concerning this result.
(i) The gradient of the GEM objective function w.r.t. the parameters of policy is expressed as a standard policy gradient, and so one can use a conventional policy gradient solver to efficiently optimise the GEM policy with the reward r GEM t . In our experiments, we use a standard V-Trace Actor-Critic approach Espeholt et al. [2018].
(ii) As these two gradient terms correspond to the same objective function, one can simultaneously optimise π and g together through a single optimisation procedure, avoiding the need for alternating optimisation techniques. The fact that the geometry-aware MSVE problem can be solved efficiently in this way may seem surprising, as its solution is the same as the intractable optimization problem of Eq. 2. The difference is that GEM casts the problem of geometry-aware MSVE as a joint optimisation in terms of the exploration policy π as well as g. In this larger function space the problem of geometric-aware MSVE is no longer intractable and can be solved efficiently, unlike the optimization problem of Eq. 2 in which only π is optimised. (iii) The main GEM objective (Eq. 5) can be further generalised to maximise a geometry-aware version of Tsallis entropy. See Appendix A for details.

Learning a Similarity Function
So far, we have assumed that a similarity function k(x, x ) has been given. However, we would ideally like to learn a geometrically meaningful k from data as a part of GEM. One can simply learn the similarity function by maximising GEM w.r.t. k as well. If we do this in the finite, discrete case, we can recover Corollary 3.0.1 from Theorem 3.1 as shown in the following proposition: Proposition 3.1.2. If X is a finite set, then max k,g,π GEM k (g, π) = H(p π E ) is attained for k (x, x ) = 1(x = x ) and g (x, π) = 1/p π E (x).
Note that k converges to an indicator function. However, in the continuous case, trying to converge to the indicator function makes the whole problem ill-defined. To show this effect, we use GEM to learn a simple 1D bi-modal Gaussian mixture. We parameterise g with a small MLP. We consider two versions of k: (i) one version is fixed with k(x, x ) = e −2|x−x | which represents what we think a good similarity function should be, and (ii) we parameterise k using a neural network embedding function f as k(x, x ) = e − f (x)−f (x ) 2 and maximise over it as well. For the distributions to be learned, we consider both a discretised and the continuous version of the simple 1D bi-modal Gaussian mixture. Fig. 1 shows the learned probabilities and densities computed from g for the four configurations. For the discrete distribution shown on the left, both a fixed and a learned similarity function perform well and can approximate the probability distribution. For the continuous case on the right, the fixed similarity learns a close approximation, while the learned similarity collapses into a uniform distribution. The reason for the collapse is that the non-linear embedding function f is able to flatten out the data distribution, converting the original distribution into a uniform distribution; which is the maximum entropy distribution.
Therefore, in all but the simplest cases, we cannot solely learn a similarity function through maximising the GEM objective. In general, we may need to rely on domain-specific knowledge in order to learn a well-structured and meaningful similarity function. Nonetheless for MDPs, it is possible to learn a generic yet meaningful similarity based on temporal structure. We keep the parameterisation of the similarity function as k(x, x ) = e −c f (x)−f (x ) 2 , and augment our objective with an additional regularization term on the embeddings f , which we call adjacency regularisation. The adjacency regularisation (AR) is a generalised pseudo-Huber loss with exponent q and offset δ: . This regularisation pulls together the embeddings of timeadjacent states. Combined with GEM, which tries to expand the distance between embeddings, this trains an embedding where approximately the closest states are those that are 1-step apart; the second closest states are those that are 2-steps apart; and so on and so forth. This is similar to the notion of reachability [Savinov et al., 2018], which tries to learn the expected shortest number of steps between any two states. We note that the higher values of exponent q are more robust to distribution shift and relate closer to a reachability distance. In our experiments we find than that q = 4 works well.
Note that AR is symmetric in time. This means that AR ends up averaging the contribution of asymmetric transitions. For example, a one-way transition between x t and x t+1 is approximately equivalent to a symmetric transition with probability 0.5.

GEM Algorithm
The final GEM algorithm is the combination of the geometry-aware GEM objective, AR, and maximising the environment reward (see Algorithm 1). To train the embedding f we optimise the combination of the AR objective and GEM objective (Line 10). To train g, we maximise the empirical GEM objective (Line 8). 1 Finally, to train π, we use a policy gradient algorithm (Line 9). Note that π is optimised with respect to the empirical estimate of the GEM objective function plus the environment reward, aimed at striking a balance between MSVE exploration and exploitation. More details on the algorithm is in Appendix B.

GEM Experiments
In this section, we conduct in-depth experimental analyses of various aspects of the GEM algorithm. All plots show 95% confidence intervals over 5 seeds. The details on the implementation and the choice of hyperparameters are in Appendix B.

Intrinsic Reward Normalization
The magnitude and variance of the intrinsic reward can vary greatly across different environments. To mix Algorithm 1: Pseudocode of GEM Inputs: neural networks g and f , policy π, Huber offset δ, Huber exponent q, regularisation scale c For every x t draw a randomly shuffled sample PolicyGradientStep for max π t R t from Eq. 6 10 Take gradient step for 1/q intrinsic and extrinsic rewards in a consistent way in our experiments, we first standardise, scale, and shift our intrinsic reward is an exponential running average of the mean (respectively standard deviation) of the intrinsic reward, and s and m are hyperparameters for the new standard deviation and mean. We then sum this normalized intrinsic reward with the extrinsic reward R t = r t + r GEM t . We found that using this more general normalisation scheme allows GEM to be robust to different resolutions of the learned embedding and different sizes of environments.

Comparisons with Baselines
To test the basic exploration capabilities of GEM, we start with a simple 2-Rooms gridworld environment consisting of two rooms and a bottleneck connection (Fig. 2). The agent starts in the top-left-hand corner, and thus must go all the way to the right and then down to pass the bottleneck in order to reach the goal in the bottom-left corner.
To test the ability to do exhaustive exploration, we designed a tree-like gridworld: 16-Leaves (Fig. 2). The agent starts near the centre, and needs to branch off in multiple directions, ending up in one of the 16 "leaves". Every episode, one of the green squares in a leaf is randomly picked, and a reward block is placed there; all the other green squares become normal free squares. Moreover, each episode is barely long enough for an agent to reach the end of one leaf. Therefore, an agent must exhaustively explore all leaves in order to learn that visiting the green square results in a reward. Importantly, the agent must be able to visit different leaves across episodes. In both the 2-Rooms and 16-Leaves environments, the agent is given as input an RGB observation from which it must learn to extract relevant features with a deep convolutional neural network. Figure 2: 2-Rooms and 16-Leaves gridworld environments. Every episode, the agent spawns randomly in one blue square, and a reward spawns randomly in one of the green squares.

Comparison with the Empirical Oracle MSVE
In this experiment we compare the performance of GEM with an idealised variant of alternating optimisation approach taken by some prior work [Lee et al., 2019, Pong et al., 2019. The basic alternating optimisation approach is to first estimate the stationary distribution over states p π (x), often using a generative model or a non-parametric estimate such as kernel-density estimation. Then the intrinsic reward is set to be − log p(x), in order to drive the policy towards less visited states.
We use an empirical oracle to estimate the stationary distribution p π (x), by using an exponential moving average of visitation counts of the true states, which is essentially the best that can be done for these simple, discrete domains. Note that this uses privileged information on the state index to get access to the true statevisitation counts from the environment. Thus, this is not a practically implementable approach in larger or continuous domains. Also note that no geometry-aware information is being used; standard Shannon entropy is being maximised over the true states.
We simulate an alternating optimisation scheme that updates the counts every step, but only updates the policy every n steps, where n ∈ {1, 5, 10}. This simulates the effect of letting the inner optimization take more gradient steps in order to be more accurate for the case when using function approximation. Because we use true counts, our alternating optimisation is stable even for n = 1, but in general with function approximation, n > 1 may be necessary for stability. fast as the idealised case of n = 1, and multiple times faster than larger values of n. These results show that the GEM algorithm is very efficient and confirms that it does not require complex optimization schemes to be stable; everything is optimized and updated together. Furthermore, the reason GEM is able to match the oracle even with function approximation is because GEM takes advantage of geometry information, which allows GEM to focus exploration on more interesting states. See Section 4.3.1 for a more in-depth look at how geometry affects GEM exploration.

Comparison with NGU and RND
Here, we compare against 3 baselines: RND, NGU without RND, and NGU with RND. RND (Random Network Distillation) is a simple technique that computes an intrinsic reward based on prediction error of predicting a fixed, random projection of the observation [Burda et al., 2018]. It is an example of a transient intrinsic reward that eventually vanishes. NGU (Never Give Up) keeps an episodic memory of visited state embeddings, and computes an intrinsic reward for the next state that is inversely correlated with its distance to previously visited states [Badia et al., 2020b]. NGU converges to a policy that tries to visit diverse states within an episode, but has no incentive to be diverse across episodes. The combination of NGU with RND uses NGU to be diverse within episodes, and relies on RND to be diverse across episodes and across training, and is state-of-the-art for exploration on Atari [Badia et al., 2020a]. The behaviour of the GEM algorithm is similar to NGU with RND, as trying to maximize entropy implies diversity both within an episode and across episodes in order to visit all states. However GEM is able to achieve this kind of behaviour through a single, simple, principled objective, without needing to add extra components.
From Fig. 4 we see the shortcomings of NGU without RND, which is not able to be diverse across episodes, and thus is not able to efficiently explore all the different leaves of 16-Leaves, and converges to a sub-optimal policy. RND is also not very effective, as it is slow and unstable, and heavily dependent on neural network architecture. NGU with RND is able to combine the best of both and consistently solves all tasks. Finally, GEM is also able to achieve the best of both worlds and be faster at solving the gridworld tasks.
MountainCar and CartpoleSwingup domains are standard, sparse-reward environments. Both are continuous-state domains with asymmetric transitions. We see that although the AR used in the GEM objective is symmetric, GEM has no problem learning a useful state embedding and similarity function for solving these tasks, and is comparable with baselines.

Impact of Adjacency Regularization
In this section, we show the effect of using adjacency regularization (AR) to shape the embeddings and similarity function. We compare GEM with and without AR on the 2-Rooms environment. We also test on a noisy version of the environment, where we add a square whose colour is randomly chosen from 65536 different colours at every step.
In Fig. 5, we see that when using AR, there is no difference in performance between noiseless and noisy environments. On the other hand, without AR, the agent completely fails to solve the noisy task. In fact,  it fails improve upon a uniformly random policy.
Taking a closer look, we examine the embeddings learned for the 4 different settings. Fig. 6 shows the first two principal components of the learned embeddings. We see that AR is able to learn the grid-like geometry of 2-Rooms and is completely robust to noise. However, without AR, the learned embeddings are completely random, and are heavily impacted by the noise instead of ignoring it. Since the noise is a much larger source of entropy than the agent position, GEM can trivially maximize entropy by just paying attention to the noise. Further insights into the structure of learned embeddings can be found in Appendix C.

Embedding Resolution
In this section, we examine how the exploration behavior of GEM is affected by the resolution of the embeddings and the similarity function. We can make the resolution finer by making the distance between embedding points larger, and thus less similar (a coarser resolution means distances are smaller, and thus states are more similar). This can be done by increasing the Huber offset δ in AR (Eq. 8), or decreasing the scale of the regularisation c in the total loss. We compare three different resolutions: coarse (δ = 0.3, c = 20), medium (δ = 0.6, c = 10), and fine (δ = 1, c = 1). Fig. 7 shows the true visitation entropy achieved for these resolutions, with finer resolutions resulting in larger entropy. This is because coarser embeddings cluster states closer together, leading to a smaller effective state space and a smaller maximum visitation entropy. A different illustration of this phenomenon is given in Fig. 7, which shows the visitation heatmaps in 2-Rooms for the three resolutions. For the fine case, the state-visitation distribution is close to uniform in each of the rooms, whereas for the medium case it becomes skewed towards the room boundaries. This is due to states in the middle of the rooms being clustered together, while the opposite boundaries of the room are dissimilar enough that they count as distinct states. Finally, for the the coarse case, the embeddings are so close together that they effectively form a line and there is no entropic incentive to deviate from a single path.
These results show that the exploratory behavior can be modified by tuning the resolution of the embeddings. In particular, the ability to reduce the effective state space size by employing coarser embeddings is especially important when scaling up the algorithm to larger and larger state spaces.

Related Work
Prior work in MSVE exploration used an iterative algorithm that requires retaining a mixture of all past policies as well as kernel density estimation for estimating densities [Hazan et al., 2018], which is hard to scale to larger and complex domains for which a kernel is hard to define. Approximations were later which improved computational complexity but only for the tabular setting [Mutti and Restelli, 2020]. Maximum entropy can also be viewed as trying to match the state-visitation distribution to a uniform distribution, as a special case from [Lee et al., 2019], which casts the problem as a two-player minimax game. Thus this approach requires the use of alternating optimisation schemes which need additional optimisation tweaks to be stable. It is also possible to estimate differential Shannon entropy using non-parametric k-nearest neighbour methods [Beirlant et al., 1997], however their connection to geometry-aware Shannon entropy is unclear. Beyond geometry-aware Shannon entropy, there is work on other entropy measures that are geometrically-aware such as Sinkhorn negentropy [Mensch et al., 2019].
Maximising diversity instead of entropy is a similar objective that tries to visit as many different states as possible. Approaches such has maximising diversity between trajectories can be used to discover skills for reaching diverse sets of states Other approaches that use intrinsic rewards for exploration design such exploration bonuses to compute a non-stationary, decaying novelty [Strehl et al., 2006, Bellemare et al., 2016, Schmidhuber, 1991 and therefore are more difficult to optimise as well as they do not come with a straightforward way to inject structure. Yet another approach is to try finding policies that look for the stochastic shortest path [Tarbouriech et al., 2019, Cohen et al., 2020. A more global approach is taken by Jin et al.
[2020] which defines reward-free reinforcement learning as a quest for generating a given number of reward-free trajectories.
GEM can be seen as a noise-contrastive approach [Gutmann andHyvärinen, 2010, Ozair et al., 2019] for MSVE, where both positive and negative distributions are built upon the same underlying distribution [Wu et al., 2018]. There are key innovations in the design of the GEM objective through which we generalise the noise-contrastive approach to tackle the MSVE exploration problem at scale. In particular, (i) GEM uses different losses for the positive and negative examples, resulting in an asymmetric loss that maximises the Shannon entropy, and (ii) GEM deploys a similarity function between pairs of states through which GEM can generalize its estimation of state-visitation distributions to continuous spaces.
Finally, AR regularisation has been previously used to learn the state representation in the control literature [Lesort et al., 2018] under the name slowness feature analysis [Wiskott andSejnowski, 2002, Böhmer et al., 2015]. However in prior work AR is used as an auxiliary task for RL or imitation learning. Whereas in GEM AR regularisation is an indispensable component of the main algorithm.

Conclusion
In this paper, we introduced GEM, Geometric Entropy Maximisation, a new approach for exploration in RL, with two main contributions. First, our key theoretical contribution is casting geometry-aware maximum state-visitation entropy as the tractable problem of optimising a simple, novel noise-contrastive objective. Second, to capture the geometry of the domain, we equip GEM with a similarity function, learned through Adjacency Regularisation (AR), a simple regularisation term added to the GEM objective. AR allows us to learn a similarity function that preserves the temporal structure of the MDP in our embeddings. We have numerically evaluated GEM on discrete-and continuousstate sparse reward problems where we can analyse and measure exploratory behaviour, and we have shown that our approach is efficient and robust to noise. By maximising the overall entropy of the state-visitation distribution, we allow for both inter and intra-episode diversity of states.

A.1 From NCE to the GEM Objective Function
The main GEM idea can be traced back to noise-contrastive estimation (NCE) [Gutmann and Hyvärinen, 2010]. The core idea of NCE is to learn to contrast between two separate distributions, with positive examples drawn from p + and negative examples drawn from p − . For this we often use a classifier h(z) = g(z) 1+g(z) , with g(z) is some positive function often paramterised as g(z) = e s(z) , where s(z) are the classifier logits. The objective of NCE is then a binary logistic regression maximisation: Then at the optimum, g(z) will converge to the ratio of the probabilities p + (z) p − (z) . In order to extract a single probability rather than a ratio of probabilities, we need to pick specific positive and negative distributions. Similar to [Wu et al., 2018], we turn the contrastive objective into an auto-contrastive objective where we pick positive examples z to be the fully correlated pair (x, x) of samples, and the negative examples to be the pair of fully independent samples (x, x ) of some random variable x, x ∼ p. Then intuitively, the probability of positive examples is p(x), the probability of negative examples is p(x)p(x), and thus the ratio is g(z) = g(x, x) = p(x) p(x)p(x) = 1/p(x). Thus the auto-contrastive objective can be used to estimate probability distributions.
In the context of maximum entropy exploration the cross-entropy objective of Eq. 9 can be used to obtain estimates of state-visitation probabilities in the auto-contrastive regime. However the auto-contrastive objective based on Eq. 9 does not represent a standard notion of entropy by which we desire to tackle the problem of maximum state-visitation entropy (MSVE) exploration. In order to connect back to Shannon entropy, we need to significantly modify the auto-contrastive objective function and turn to using an asymmetric, objective between positive and negative examples as follows where h is constrained to be non-negative. This is the origin of Eq. 3. As we have shown in Proposition 3.0.1, maximising this objective gives us the MSVE policy π E .
Proof. The objective is restated here: To find the maximiser of the objective, we break down the maximization to first maximise for h, and then maximise for π: So first we try to maximise h. Since X is discrete, we can consider h(x, x ) a matrix of variables, where we have a variable for every x, x ∈ X . Then we write out the expectations in terms of sums: Note that h(x, x ) for x = x only appears as a negative term as the second term. Thus, the maximum of zero can be attained by setting h(x, x ) = 0. Thus we can simplify the objective by only considering the variables when x = x , and the letting g x = h(x, x): x p π (x)p π (x)g x + 1.
Since g x is a separate variable for every x, we can maximise this sum by maximising every term of the sum w.r.t.
x, reducing this to the following single variable problem: First, note that when p π (x) = 0, the objective becomes a constant, and therefore does not matter when trying to maximise g(x); g(x) can take on any value. Thus from now on we only consider x such that p π (x) > 0.
Then, we can find the critical points by setting the derivative to zero: To see what kind of critical point this is, we compute the second derivative: Since we are only considering p π (x) > 0, then this second derivative − 1 g 2 x p π (x) < 0. This means that the critical point is a local maximum. Furthermore, since there is only one critical point, and the second derivative is always negative, this local maximum is the global maximum. Thus g x = 1 p π (x) . This also means that Plugging this back into GEM: We get that maximising w.r.t. h results in simply the Shannon entropy of p π . Finally, we put it together to get: Thus the maximiser for π is the optimal Shannon MSVE policy π E = argmax π H(p π ).
Proof. This corollary follows immediately from the proof of Proposition 3.0.1.
Proof. We restate the full, geometry-aware GEM objective function here: Recall that the similarity profile is p π k (x) = E x ∼p π [k(x, x )]. Then we can slightly rewrite the GEM as follows: We then follow the same proof structure as for the proof for Proposition 3.0.1, to first prove the result for the finite case. We first decompose the maximisation into first maximising for g, and then maximising for π: Then we reduce the problem of maximising g to pointwise maximisation of each separate variable g x = g(x) of the following: Solving for the critical point we get, similar to before, that: where instead of p π (x) we now get the similarity profile p π k (x). By the same argument as in the proof for Proposition 3.0.1, the second derivative is negative, and thus this is the global maximum. Plugging this back in, we get that max g,π GEM k (g, π) = max π max g GEM k (g, π) (34) Where the maximiser for π is π E = argmax π H k (p π ), the geometry-aware Shannon MSVE policy.
Extension to the continuous case. In this case we start by similarly decomposing the maximisation: From the proof of the discrete case, we know that g x = 1 p π k (x) is the pointwise maximiser for g(x) for every x inside the expectation. Thus, this is also the maximiser for the entire expectation, as maximising pointwise is the best that we can do. Therefore the result also holds for continuous distributions (the similarity profile p π k (x) is well-defined when the similarity k is smooth and nicely integrable).
A.5 Proof of Proposition 3.1.1 Proposition 3.1.1. Let π and g be approximated by some differentiable function approximators with sets of parameters θ and ξ respectively. Let r GEM , where x t is drawn independently from p π at every time step t. Then unbiased estimates of the gradient of GEM objective w.r.t. θ and ξ are, respectively, and Proof. We notice that the gradient term in Eq. 7 is an unbiased empirical estimate of the gradient of GEM w.r.t. the parameters of g. In the case of ∇ θ GEM k (g, π) given the fact that k is a symmetric function of x and x we have the following from the product rule From the policy gradient theorem [Sutton et al., 1999] we deduce where the outer expectation is with respect to the stochastic process induced by the policy π. The result then follows by replacing the expectations with their empirical estimates along the trajectory (x 1 , x 2 , . . . , x T ).
Proof. We restate the full GEM objective here: We know from Theorem 3.1 that where g = 1 p π k (x) . Then let's further maximise w.r.t. k: In order to maximise this expression, we want to minimise the sum inside the logarithm. However we cannot simply set k(x, x ) = 0, as we are constrained by requiring that k(x, x) = 1. Therefore we let k(x, x) = 1, and for all x = x , we can set k(x, x ) = 0. This is equivalent to setting k(x, x ) = 1(x = x ). Thus and plugging that in we get: and we recover the discrete Shannon entropy.

A.7 Generalization of GEM to Tsallis Entropy
Tsallis Entropy. Tsallis entropy is defined as [Tsallis, 1988]: for the real α. Taking the limit as α → 1, this simplifies to Shannon entropy. Tsallis entropy is sometimes called a pseudo-entropy since it satisfies all the properties of the standard entropy except additivity [Tsallis, 1988]. Here, we extend this definition to a geometry-aware version of Tsallis entropy (similar to geometry-aware Shannon entropy) by replacing p with its similarity profile p k : We now introduce the generalisation of the GEM objective function: where α < 2. For α = 1, we take the limit of (α − 1) → 0 and use the identity lim δ→0 x δ −1 δ = ln x to recover the Shannon case: Next, for α = 1, we follow the structure of the proof for the Shannon case. We first decompose the maximisation: Then we proceed to do a pointwise maximisation for g x = g(x): Note again that for p π (x) = 0, this becomes a constant and g x can take on any value. Thus we restrict ourselves to the case where p π (x) > 0. We find the critical point by solving for the zeros of the derivative: Thus the critical point is identical to the Shannon case. Next we examine the second derivative: We plug in the critical point and this second derivative simplifies to: So this critical point is a maximum as long as α < 2. Thus the maximiser g is exactly the same as for the Shannon case: Plugging this back into the full objective we get: Thus we are able to find the geometry-aware Tsallis MSVE policy with this generalised GEM.

B Experiment Details
B.1 1D bimodal Gaussian Learning for Section 3.2.1 Algorithm 2: soft1hot(x) Inputs: x, n bucket , m min , m max 1 Let y x−mmin mmax−mmin ; 2 Let b {0.5, 1.5, 2.5, . . . , n bucket − 0.5} ; 3 Return {e −n bucket |bi−y| | b i ∈ b} ; Algorithm 3: GEMLoss(B 1 , B 2 ) Inputs: In this part, we provide experimental details for GEM in Fig. 1 given in Section 3.2.1. The loss is computed in Algorithm 3 and optimised with the ADAM optimiser. Note that we use the softplus activation on top of g to make sure that it always returns something positive. We also add a small regularisation to the norm of the output of f (REG) to prevent divergence to infinity.
Next, we outline the data generating distribution. Let N, N ∼ TruncNorm(0, 1) be a random variable from the standard truncated normal normal distribution with mean 0, variance 1, truncated between {−2, 2}. Let U ∼ Uniform(0, 1) be a random variable from the uniform distribution in [0, 1]. Then the bimodal distribution used for generating data is X has been scaled and shifted so that its support is [0, 30]. The discretised version has 30 points equally spaced in [0,30], where the probability is computed by normalizing the density values at those 30 points. In order to take full advantage of neural networks, we use a soft-one-hot encoding (Algorithm 2) of the scalar input before passing it to the inner layers of the neural networks of f and g. Experiment hyperparameters are outlined in Table 1.

B.2 GEM Experiment Details
The plots in the experiments (Section 4) are computed by splitting the x-axis into 20 buckets of equal size, and computing the average of each bucket. This is done to smooth the data for each individual run. Then 5 runs are averaged together, and the standard error with 95% confidence interval is computed and shown as the shaded region.
The dynamics of the gridworlds in Fig. 2 have 5 standard actions of [no-op, up, down, left, right]. The initial state of the agent is picked uniformly at random from any of the blue square locations. The blue locations not chosen are normal free blocks. In each episode, a random green square location is chosen and a reward block (with reward 1.0) is placed there. The green locations not chosen are normal free blocks. The episode ends after the agent moves over the reward block and sees the reward. Adam(learning rate = 10 −3 , β 1 = 0, β 2 = 0.95) The episode length for 2-Rooms is 30, and 16-Leaves is 18. The state representation of these environments are pixel image arrays, i.e., 3D arrays of shape (width, height, 3), and are shown in Fig. 8; they consists of an upper world map, which shows a map of the rooms as well as which room the agent is in and which room the reward is in, and a lower room map, which shows the map of the current room. In the noisy version of 2-Rooms, there is a square with random red and green components (256 2 different colours) in-between the upper and lower maps. Each square is 8 × 8 pixels.
The visitation entropy (Fig. 7) is tracked by keeping an exponential moving average with a decay of 0.99 of the visitation count for each open square, and then computing the empirical Shannon entropy over these counts. The heatmaps (Fig. 7) are generated using the same counts, but are normalised by dividing all counts by the largest count so that the most visited square has value 1, corresponding to pure black.
The environments Cartpole Swingup and Mountain Car are standard, continuous-state, sparse reward domains with episode length 1000. We use the implementations of [Osband et al., 2020].
A training step is outlined in Algorithm 6. The AR loss is computed from Algorithm 4. We compute the GEM intrinsic reward from Algorithm 3, normalise it, and mix it with the extrinsic reward to use for policy gradient (Algorithm 5) to train π and V , which is a standard actor-critic algorithm. g and f are optimised directly with the computed loss.
For all experiments, we use a multi-process agent, where we have 64 processes running the agent policy and gathering data from the environment in parallel. The data is gathered and sent to another processes that computes the gradients and updates the parameters.
The basic network architecture used is shown in Table 2, along with training hyperparameters. For the continuous domains of Cartpole Swingup and Mountain Car, we use a slightly different architecture since their state is not an image (Table 3). The RNN cores for the value V and policy π networks take as input the concatenation of the torso output (torso is applied to the state), a 1-hot representation of the previous action, the previous extrinsic reward, and a soft 1-hot representation of the current timestep index. The embedding function f and the g function only take state as input, without concatenating other quantities. The batch size in Table 2 denotes the total batch size, i.e. it is the combination of B 1 and B 2 in Algorithm 6, each of which is half of the size. Each minibatch contains batch size number of traces, which are short segments of episodes. The trace period denotes which indices the traces start. For example, a trace length of 20 with a trace period of 10 means that the traces are timesteps (1, 2, . . . , 20), (10, 11, . . . , 30), (20, 21, . . . , 40), etc.. The traces are randomly chosen from within the episode so that the traces are not all in lockstep within a minibatch. The trace lengths and trace periods are shown in Table 4.

C.1 Irreversible Transitions
Because AR is symmetric, we take a closer look in this section as to what happens when we have asymmetric dynamics. We ran GEM on the simple gridworld illustrated in Fig. 9 (with image representation shown in Fig. 8).
The agent spawns at random in one of the blue cells, and the goal is in the green cell. To cross the bottleneck brown cell (the "door"), the agent must first visit at least one of the yellow cells (the "keys"). Visiting a yellow cell ("collecting the key") turns it into an ordinary cell, as does visiting the brown door cell after having a key ("opening the door"). Thus both picking up the key and opening the door are asymmetric, irreversible transitions. Fig. 10 shows learned embeddings for different states, projected onto the first two principal components. The different markers denote different configurations of the state (ignoring the agent position), and the colors correspond to different positions on the grid. For example, the blue circles correspond to the positions on the top room before having collected any keys. The purple positions correspond to the second room, and we can see that different configurations are embedded differently. In particular, the embedding groups the lower-room states into three (purple) groups: In the left group (+) the agent has only collected the lower key, in the center group ( ) the agent has collected both keys, and in the right group (|) the agent has only collected the upper key. The terminal state (where the green goal is absent) is also embedded separately for each of the three groups. The blue regions (lower room) are similarly grouped by the configuration of the keys and the door. Fig. 10 contains a more detailed description of the different configuration and position representations.
The main difference between the symmetric transitions and the asymmetric transitions is that asymmetric transitions results in embedding points that are slightly farther away from each other. This is because we only optimise AR for one direction as opposed to both directions with symmetric transitions, i.e., the strength of adjacency regularization is halved. Nevertheless, the embeddings learned is still meaningful and GEM is still able to explore and solve this task.