Year: 2021

Abstract:
We introduce Contrastive Intrinsic Control (CIC) an algorithm for unsupervised skill discovery that maximizes the mutual information between skills and state transitions. In contrast to most prior approaches, CIC uses a decomposition of the mutual information that explicitly incentivizes diverse behaviors by maximizing state entropy. We derive a novel lower bound estimate for the mutual information which combines a particle estimator for state entropy to generate diverse behaviors and contrastive learning to distill these behaviors into distinct skills. We evaluate our algorithm on the Unsupervised Reinforcement Learning Benchmark, which consists of a long reward-free pre-training phase followed by a short adaptation phase to downstream tasks with extrinsic rewards. We find that CIC improves on prior unsupervised skill discovery methods by 91% and the next-leading overall exploration algorithm by 26% in terms of downstream task performance.

heading: 1 INTRODUCTION
text: max I(s; z) = max (ℋ(s) − ℋ(s |z)) z1
z2 z3
Figure 1: This work deals with unsupervised skill discovery through mutual information maximization. We introduce Contrastive Intrinsic Control (CIC) – a new unsupervised RL algorithm that explores and adapts more efficiently than prior methods.
Deep Reinforcement Learning (RL) is a powerful approach toward solving complex control tasks in the presence of extrinsic rewards. Successful applications include playing video games from pixels (Mnih et al., 2015), mastering the game of Go (Silver et al., 2017; 2018), robotic locomotion (Schulman et al., 2016; 2017; Peng et al., 2018) and dexterous manipulation (Rajeswaran et al., 2018; OpenAI, 2018; 2019) policies. While effective, the above advances produced agents that are unable to generalize to new downstream tasks beyond the one they were trained to solve. Humans and animals on the other hand are able to acquire skills without supervision and apply them efficiently to a variety of downstream tasks. In this work, we seek to train agents that acquire skills without supervision with generalization capabilities by efficiently adapting these skills to downstream tasks.
Over the last few years, unsupervised RL has emerged as a promising framework for developing RL agents that can generalize to new tasks. In the unsupervised RL setting, agents are first pre-trained with self-supervised intrinsic
rewards and then finetuned to downstream tasks with extrinsic rewards. Unsupervised RL algorithms broadly fall into three categories - knowledge-based, data-based, and competence-based methods1. Knowledge-based methods maximize the error or uncertainty of a predictive model (Pathak et al., 2017; 2019; Burda et al., 2019b). Data-based methods maximize the entropy of the agent’s visitation (Liu & Abbeel, 2021a; Yarats et al., 2021b). Competence-based methods learn skills that generate diverse behaviors (Eysenbach et al., 2019; Gregor et al., 2017). This work falls into the latter category of competence-based methods.
1These categories for exploration algorithms were introduced by Srinivas & Abbeel (2021) and inspired by Oudeyer et al. (2007).
Unlike knowledge-based and data-based algorithms, competence-based algorithms simultaneously address both the exploration challenge as well as distilling the generated experience in the form of reusable skills. This makes them particularly appealing, since the resulting skill-based policies (or skills themselves) can be finetuned to efficiently solve downstream tasks. While there are many self-supervised objectives that can be utilized, our work falls into a family of methods that learns skills by maximizing the mutual information between visited states and latent skill vectors. Many earlier works have investigated optimizing such objectives (Eysenbach et al., 2019; Gregor et al., 2017; Kwon, 2021; Sharma et al., 2020). However, competence-based methods have been empirically challenging to train and have under-performed when compared to knowledge and data-based methods (Laskin et al., 2021).
In this work, we take a closer look at the challenges of pre-training agents with competence-based algorithms. We introduce Contrastive Intrinsic Control (CIC) – an exploration algorithm that uses a new estimator for the mutual information objective. CIC combines particle estimation for state entropy (Singh et al., 2003; Liu & Abbeel, 2021a) and noise contrastive estimation (Gutmann & Hyvärinen, 2010) for the conditional entropy which enables it to both generate diverse behaviors (exploration) and discriminate high-dimensional continuous skills (exploitation). To the best of our knowledge, CIC is the first exploration algorithm to utilize noise contrastive estimation to discriminate between latent skill vectors. Empirically, we show that CIC adapts to downstream tasks more efficiently than prior exploration approaches on the Unsupervised Reinforcement Learning Benchmark (URLB). CIC achieves 91% higher returns on downstream tasks than prior competence-based algorithms and 26% higher returns than the next-best exploration algorithm overall.

heading: 2 BACKGROUND AND NOTATION
text: Markov Decision Process: We operate under the assumption that our system is described by a Markov Decision Process (MDP) (Sutton & Barto, 2018). An MDP consiss of the tuple (S,A,P, r, γ) which has states s ∈ S, actions a ∈ A, transition dynamics p(s′|s, a) ∼ P , a reward function r, and a discount factor γ. In an MDP, at each timestep t, an agent observes the current state s, selects an action from a policy a ∼ π(·|s), and then observes the reward and next state once it acts in the environment: r, s′ ∼ env.step(a). Note that usually r refers to an extrinsic reward. However, in this work we will first be pre-training an agent with intrinsic rewards rint and finetuning on extrinsic rewards rext.
For convenience we also introduce the variable τ(s) which refers to any function of the states s. For instance τ can be a single state, a pair of states, or a sequence depending on the algorithm. Our method uses τ = (s, s′) to encourage diverse state transitions while other methods have different specifications for τ . Importantly, τ does not denote a state-action trajectory, but is rather shorthand for any function of the states encountered by the agent. In addition to the standard MDP notation, we will also be learning skills z ∈ Z and our policy will be skill-conditioned a ∼ π(·|s, z). Unsupervised Skill Discovery through Mutual Information Maximization: Most competencebased approaches to exploration maximize the mutual information between states and skills. Our
work and a large body of prior research (Eysenbach et al., 2019; Sharma et al., 2020; Gregor et al., 2017; Achiam et al., 2018; Lee et al., 2019; Liu & Abbeel, 2021b) aims to maximize a mutual information objective with the following general form:
I(τ ; z) = H(z)−H(z|τ) = H(τ)−H(τ |z) (1)
Competence-based algorithms use different choices for τ and can condition on additional information such as actions or starting states. For a full summary of competence-based algorithms and their objectives see Table 1 in Appendix D.
Lower Bound Estimates of Mutual Information: The mutual information I(s; z) is intractable to compute directly. Since we wish to maximize I(s; z), we can approximate this objective by instead maximizing a lower bound estimate. Most known mutual information maximization algorithms use the variational lower bound introduced in Barber & Agakov (2003):
I(τ ; z) = H(z)−H(z|τ) ≥ H(z) + E[log q(z|τ)] (2)
Note that the variational lower bound can be applied to both decompositions of the mutual information. The design decisions of a competence-based algorithm therefore come down to (i) which decomposition of I(τ ; z) to use, (ii) whether to use discrete or continuous skills, (iii) how to estimate H(z) or H(τ), and finally (iv) how to estimate H(z|τ) or H(τ |z).

heading: 3 MOTIVATION
text: The results from the recent Unsupervised Reinforcement Learning Benchmark (URLB) introduced in Laskin et al. (2021), suggest that pre-training with competence-based approaches underperforms relative to knowledge-based and data-based baselines on DeepMind Control (DMC). We argue that the underlying issue with current competence-based algorithms when deployed on harder exploration environments like DMC has to do with the currently used estimators for I(τ ; z) rather than the objective itself. To produce structured skills that lead to diverse behaviors, I(τ ; z) estimators must (i) explicitly encourage diverse behaviors and (ii) have the capacity to discriminate between high-dimensional continuous skills. Current approaches do not satisfy both criteria.
Competence-base algorithms do not ensure diverse behaviors: Most of the best known competencebased approaches (Eysenbach et al., 2019; Gregor et al., 2017; Achiam et al., 2018; Lee et al., 2019), optimize the first decomposition of the mutual information H(z) − H(z|τ). The issue with this decomposition is that while it ensures diversity of skill vectors it does not ensure diverse behavior from the policy, meaning maxH(z) does not imply maxH(τ). Of course, if H(z) − H(z|τ) is maximized and the skill dimension is sufficiently large, thenH(τ) will also be maximized implicitly. Yet in practice, to learn an accurate discriminator q(z|τ), the above methods assume skill spaces that are much smaller than the state space (see Table 1), and thus behavioral diversity may not be guaranteed. In contrast, the decomposition I(τ ; z) = H(τ) − H(τ |z) ensures diverse behaviors through the entropy term H(τ). Methods that utilize this decomposition include Liu & Abbeel (2021b); Sharma et al. (2020).
Why it is important to utilize high-dimensional skills: Once a policy is capable of generating diverse behaviors, it is important that the discriminator can distill these behaviors into distinct skills. If the set of behaviors outnumbers the set of skills, this will result in degenerate skills – when one skill maps to multiple different behaviors. It is therefore important that the discriminator can accommodate continuous skills of sufficiently high dimension. Empirically, the discriminators used in prior work utilize only low-dimensional continuous skill vectors. DIAYN (Eysenbach et al., 2019) utilized 16 dimensional skills, DADS (Sharma et al., 2020) utilizes continuous skills of dimension 2 − 5, while APS (Liu & Abbeel, 2021b), an algorithm that utilizes successor features (Barreto et al., 2016; Hansen et al., 2020) for the discriminator, is only capable of learning continuous skills with dimension 10. We show how small skill spaces can lead to ineffective exploration in a simple gridworld setting in Appendix I and evidence that skill dimension affects performance in Fig. 6.
On the importance of benchmarks for evaluation: While prior competence-based approaches such as DIAYN (Eysenbach et al., 2019) were evaluated on OpenAI Gym (Brockman et al., 2016), Gym environment episodes terminate when the agent loses balance thereby leaking some aspects of extrinsic signal to the exploration agent. On the other hand, DMC episodes have fixed length. We show
in Appendix K that this small difference in environments results in large performance differences. In Fig. 11 we show that DIAYN is able to learn diverse skills in Gym but not in DMC, which is consistent with both observations from DIAYN and URLB papers. Due to fixed episode lengths, DMC tasks are harder for reward-free exploration since agents must learn to balance without supervision.

heading: 4 METHOD

heading: 4.1 THE CIC ESTIMATOR
text: From Section 3 we are motivated to find an estimator for I(τ ; z) that explicitly maximizes the entropy H(s) through the second decomposition I(τ ; z) = H(τ) − H(τ |z). We also desire that our method’s discriminator is capable of supporting high-dimensional continuous skills to ensure maximal behavioral diversity.2 Note that τ is not a trajectory but some function of states.
In this work, we propose a new estimator for I(τ ; z) which combines the use of a particle estimator for the entropy (Liu & Abbeel, 2021a) and noise contrastive estimation (Gutmann & Hyvärinen, 2010) for the conditional entropy. Our proposed sample-based estimator is:
FCIC (τi, zi) := Hparticle(τi) + E f(τi, zi)− log 1 N N∑ j=1 exp(f(τj , zi))  (3) where N is the number of samples, τ = (s, s′), and Hparticle(τ) is a particle estimator (Singh et al., 2003; Beirlant, 1997; Liu & Abbeel, 2021a) which estimates entropy by computing the distance between each particle hi and its k-th nearest neighbor h?i such that Hparticle(τ) ∝ ∑n i=1 log ‖hi − h?i ‖. The CIC estimator should achieve the best of both worlds – encouraging exploration through maxH(τ) and distilling behaviors into skills through contrastive representation learning. We first show that Eq. 3 is a valid lower bound for I(τ ; z). Theorem 1. Let FCIC (τ, z) be defined as in Eq. 3, we have that FCIC (τ, z) is a lower bound of the mutual information: I(τ, z) ≥ FCIC (τ, z), where f(τ, z) is any real function of τ and z.
Proof. First we find a variational lower bound for I(τ ; z) where the inequality is due to Barber & Agakov (2003).
I(τ ; z) = H(τ)−H(τ |z) ≥ H(τ) + E[log q(τ |z)], (4)
From Contrastive Predictive Coding (CPC) (Oord et al., 2018) we can also have a sample based lower bound for I(τ ; z).
2In high-dimensional state-action spaces the number of distinct behaviors can be quite large.
I(τ ; z) ≥ FCPC(τi, zi) := E f(τi, zi)− log 1 N N∑ j=1 exp(f(τj , zi))  . (5) As shown in Oord et al. (2018), this bound is upper bound by logN which means the bound will be loose when I(τ ; z) ≥ logN . To overcome this limitation, we note that we can also parameterize the variational density in Eq. 4 with a noise contrastive estimator q(τi|zi) = exp (f(τi, zi)) / ( 1 N ∑N j=1 exp(f(τj , zi)) ) . We therefore have I(τi; zi) ≥ H(τi) + FCPC(τi, zi) which completes the proof.
A favorable property of the CIC estimator is that it provides a tighter lower bound than CPC for mutual information I(τ ; z) ≥ FCIC (τ, z) ≥ FCPC(τ, z). In contrast to the CPC estimator, CIC is more suitable for exploration due to the explicit presence ofH(τ), which helps learning meaningful representations and behaviors as evident in recent work (Campos et al., 2020; Mutti et al., 2021; Liu & Abbeel, 2021a; Campos et al., 2021a; Yarats et al., 2021b) whereas Eq. 5 does not explicitly encourage exploration. On the other hand, contrastive learning has been demonstrated as a powerful approach for representation learning in vision and reinforcement learning (Chen et al., 2020; Oord et al., 2018; Laskin et al., 2020b). It is therefore interesting to combine these two objectives into a single intrinsic reward.

heading: 4.2 INTRINSIC REWARD AND INTERPRETATION OF CIC ESTIMATION
text: Intrinsic Reward: We parameterize f(τ, z) = gψ1(τ) >gψ2(z) where τ = (s, s ′) is a transition tuple and gψk are neural encoders. This inner product is similar to the one used in the SimCLR (Chen et al., 2020) representation learning loss. We then use a particle estimator (Singh et al., 2003; Beirlant, 1997) as in Liu & Abbeel (2021a) for the entropy term. Similar to Liu & Abbeel (2021a); Yarats et al. (2021b) rather than using the exact form of the particle estimator we estimate the entropy up to entropy up to a proportionality constant, and therefore introduce a hyperparameter α to weigh the entropy and CPC terms. With this parametrization the intrinsic reward for the unsupervised RL agent takes on the following form:
rint(τi, zi) := α log  1 Nk Nk∑ h?i∈Nk ‖hi − h?i ‖ + (1− α) f(τi, zi)− log 1 N N∑ j=1 exp(f(τj , zi)))  (6)
where hi is an embedding of τi shown in Fig. 3, h∗i is a kNN embedding,Nk is the number of kNNs, and N − 1 is the number of negatives. The total number of elements in the summation is N because it includes one positive.
Explore and Exploit: We can interpret the two terms of Eq. 6 as contributing two different behaviors to the exploration algorithm. The entropy term H(τ) encourages exploration by maximizing state diversity. The variational density q(τ |z) encourages exploitation by ensuring that skills z lead to predictable states τ . Together the two terms form an intrinsic reward that incentivizes diverse yet predictable behavior from the RL agent.
Asymptotic Behavior of the Intrinsic Reward: When maximum entropy is reached the H(τ) term in Eq. 6 will vanish since there are no new states to discover. Therefore asymptotically exploration will stop. However, the variational density q(τ |z) parameterized by CPC will continue distilling all states in the environment into skills z until they are maximally distinct such thatH(τ |z) = ε 1.

heading: 5 PRACTICAL IMPLEMENTATION
text: Our practical implementation consists of two main components: the RL optimization algorithm and the architecture for specifying the intrinsic reward. For fairness and clarity of comparison, we use the same RL optimization algorithm for our method and all baselines in this work. Since the baselines
implemented in URLB (Laskin et al., 2021) use a DDPG3 (Lillicrap et al., 2016) as their backbone, we opt for the same DDPG architecture to optimize our method as well (see Appendix B). For the full algorithm
Architecture for intrinsic rewards: We use a particle estimator as in Liu & Abbeel (2021a) to estimate H(s). To compute the variational density q(τ |z), we first sample skills from uniform noise z ∼ p(z) where p(z) is the uniform distribution over the [0, 1] interval. We then use two MLP encoders to embed gψ1(τ) and gψ2(z), and optimize the parameters ψ1, ψ2 with the CPC loss similar to SimCLR (Chen et al., 2020) since f(τ, z) = gψ1(τ)
T gψ2(z). We fix the hyperparameters across all domains and downstream tasks. We refer the reader to the Appendices E and F for the full algorithm and a full list of hyperparameters.
Adapting to downstream tasks: To adapt to downstream tasks we follow the same procedure for competence-based method adaptation as in URLB (Laskin et al., 2021). During the first 4k environment interactions we populate the DDPG replay buffer with samples and use the extrinsic rewards collected during this period to finetune the skill vector z. While it’s common to finetune skills with Cross Entropy Adaptation (CMA), given our limited budget of 4k samples (only 4 episodes) we find that a simple grid sweep of skills over the interval [0, 1] produces the best results (see Fig. 6). After this, we fix the skill z and finetune the DDPG actor-critic parameters against the extrinsic reward for the remaining 96k steps. Note that competence-based methods in URLB also finetune their skills during the first 4k finetuning steps ensuring a fair comparison between the methods. The full adaptation procedure is detailed in Appendix E.

heading: 6 EXPERIMENTAL SETUP
text: Environments We evaluate our approach on tasks from URLB, which consists of twelve downstream tasks across three challenging continuous control domains for exploration algorithms – walker, quadruped, and Jaco arm. Walker requires a biped constrained to a 2D vertical plane to per-
3It was recently was shown that a DDPG achieves state-of-the-art performance (Yarats et al., 2021a) on DeepMind Control (Tassa et al., 2018) and is more stable than SAC (Haarnoja et al., 2018) on this benchmark.
form locomotion tasks while balancing. Quadruped is more challenging due to a higher-dimensional state-action space and requires a quadruped to in a 3D environment to learn locomotion skills. Jaco arm is a 6-DOF robotic arm with a three-finger gripper to move and manipulate objects without locking. All three environments are challenging in the absence of an extrinsic reward.
Baselines: We compare CIC to baselines across all three exploration categories. Knowledge-based basedlines include ICM (Pathak et al., 2017), Disagreement (Pathak et al., 2019), and RND (Burda et al., 2019b). Data-based baselines incude APT (Liu & Abbeel, 2021a) and ProtoRL (Yarats et al., 2021b). Competence-based baselines include DIAYN Eysenbach et al. (2019), SMM Lee et al. (2019), and APS (Liu & Abbeel, 2021b). The closest baselines to CIC are APT, which is similar to CIC with α = 1.0 (no discriminator), and APS which uses the same decomposition of mutual information as CIC and also uses a particle entropy estimate forH(τ). The main difference between APS and CIC is that APS uses successor features while CIC uses a contrastive estimator for the discriminator. For further details regarding baselines we refer the reader to Appendix C.
Evaluation: We follow an identical evaluation to the 2M pre-training setup in URLB. First, we pretrain each RL agent with the intrinsic rewards for 2M steps. Then, we finetune tune each agent to the downstream task with extrinsic rewards in the data-efficient regime of 100k steps. We use 10 seeds across each downstream task for our method and all the baseline algorithms. For baselines, we benchmark against leading knowledge-based, data-based, and competence-based approaches that have been implemented in URLB. All baselines use the same DDPG optimization algorithm to eliminate confounding factors when comparing algorithms.
To ensure that our evaluation statistics are unbiased we use stratified bootstrap confidence intervals to report aggregate statistics across M runs with N seeds as described in Rliable (Agarwal et al., 2021) to report statistics for our main results in Fig. 4. Our primary success metric is the interquartile mean (IQM) and the Optimality Gap (OG). IQM discards the top and bottom 25% of runs and then computes the mean. It is less susceptible to outliers than the mean and was shown to be the most reliable statistic for reporting results for RL experiments in Agarwal et al. (2021). OG measures how far a policy is from optimal (expert) performance. To define expert performance we use the convention in URLB, which is the score achieved by a randomly initialized DDPG after 2M steps of finetuning (20x more steps than our finetuning budget).

heading: 7 RESULTS
text: In this section we investigate empirical answers to the following research questions: (Q1) How does CIC adaptation efficiency compare to prior competence-based algorithms and exploration algorithms
more broadly? (Q2) Qualitatively, does CIC discover structured skills and particularly is it able to do so in environments with high-dimensional state-action spaces? (Q3) Quantitatively, how does CIC behavior compare to prior methods? (Q4) Is skill selection important for efficient adaptation to downstream tasks? (Q5) How does the skill dimension affect the quality of the pre-trained policy?
Adaptation efficiency of CIC and exploration baslines: Expert normalized scores of CIC and exploration algorithms from URLB are shown in Fig. 3. We find that CIC substantially outperforms prior competence-based algorithms (DIAYN, SMM, APS) achieving a 91% higher IQM than the next best competence-based method (APS) and, more broadly, achieving a 26% higher IQM than the next best overall baseline (ProtoRL). In further ablations, we find that the contributing factors to CIC’s performance are its ability to accommodate substantially larger continuous skill spaces than prior competence-based methods.
Quantitative analysis of CIC behaviors: Quantitatively, intrinsic reward profiles during pretraining and behavior entropies are shown in Fig 5. Since the CPC and etnropy terms are on different scale, we pick a default hyparameter of α = 0.9 that puts them on equal footing. We find that the CPC intrinsic reward increases through training while the entropy term decreases to a non-zero value. This is what we would expect to see as the discriminator distills behaviors into a set of skills with lower than pure entropy maximization without skill learning. Using a particle estimator for entropy, we find that CIC behavioral entropy is less than APT and greater than DIAYN or CIC without the entropy term. This suggests that the CIC agent has learned non-static skills while DIAYN skills are mostly static. Finally, we find that CIC with α = 0.0 (no entropy) on Jaco is optimal for downstream task performance. This is most likely because, unlike Walker and Quadruped, which require locomotion, Jaco tasks require reaching a certain position, so low-entropy skills that take the end effector to a certain end position are favorable to skills that result in periodic motion.
For a qualitative analysis, we refer the reader to Fig. 2 and Appendix J.
Skill architecture and adaptation ablations: We find that projecting the skill to a latent space before inputting it as the key for the contrastive loss is an important design decision (see Fig. 6a), most likely because this reduces the diversity of the skill vector making the discriminator task simpler.
We also find empirically that the skill dimension is an important hyperparameter and that larger skills results in better zero-shot performance (see Fig. 6b), which empirically supports the hypothesis posed in Section 3 and Appendix I that larger skill spaces are important for internalizing diverse behaviors. Interestingly, CIC zero-shot performance is poor in lower skill dimensions (e.g. dim(z) < 10), suggesting that when dim(z) is small CIC likely performs no better than prior competence-based methods such as DIAYN, and that scaling to larger skill dimensions enables CIC to pre-train effectively.
To measure the effect of skill finetuning described in Section 5, we sweep mean skill values along the interval of the uniform prior [0, 1] with a budget of 4k total environment interactions and read out the performance on the downstream task. By sweeping, we mean simply iterating over the interval [0, 1] with fixed step size (e.g. v = 0, 0.1, . . . , 0.9, 1) and setting zi = v for all i. This is not an optimal skill sampling strategy but works well due to the extremely limited number of samples for skill selection.
We evaluate this ablation on the Quadruped Stand and Run downstream tasks. The results shown in Fig. 6 indicate that skill selection affects downstream task performance. The most optimal skill results in 8× better performance than the least optimal skill on Quadruped stand. Ablating the skill dimension, we evaluate the zero-shot performance of the agent in Walker Walk with a fixed skill of 0 4 and find that the zero-shot performance monotonically increases from skill dimension 4 until reaching dimension 64 and starts decreasing for even higher skill dimensions.

heading: 8 RELATED WORK
text: Supervised Reinforcement Learning: To date, most of RL research has focused on supervised RL where training is supervised with an extrinsic reward function. Supervised RL has seen many breakthroughs over the last five years (Mnih et al., 2015; Silver et al., 2017; Vinyals et al., 2019; Silver et al., 2018; Berner et al., 2019; Andrychowicz et al., 2020; Schulman et al., 2016; 2017). The field has also produced several stable RL optimization algorithms that have helped accelerated research Haarnoja et al. (2018); Hessel et al. (2018); Lillicrap et al. (2016); Schulman et al. (2017).
Unsupervised Reinforcement Learning: The sub-field of unsupervised RL consists of two primary research areas - unsupervised behavioral learning and unsupervised representation learning (Srinivas & Abbeel, 2021). Unsupervised behavioral learning consists of learning behaviors and exploring the environment without extrinsic rewards. Unsupervised representation learning consists of learning representations without supervision from high-dimensional data such as pixel observations. We evaluate our method on the recently introduced Unsupervised RL Benchmark (URLB) (Laskin et al., 2021), and focus solely on the behavioral aspect of unsupervised RL in order to isolate the core issue preventing prior unsupervised skill discovery methods from exploring effectively on URLB.
Unsupervised Behavioral Learning: The aim of unsupervised behavioral learning is to produce diverse behaviors that explore the environment without interacting with an extrinsic reward. Often referred to as intrinsic motivation (Oudeyer et al., 2007), this is typically achieved by defining an intrinsic reward through a self-supervised task. Most behavioral learning algorithms fall into three categories – knowledge-based (Pathak et al., 2017; 2019; Burda et al., 2019b;a) where the agent maximizes the error or uncertainty of some predictive model, data-based (Campos et al., 2021b; Liu & Abbeel, 2021a;b; Mutti et al., 2021; Seo et al., 2021; Yarats et al., 2021b) where the agent maximizes data diversity, and competence-based Eysenbach et al. (2019); Hansen et al. (2020); Liu & Abbeel (2021b); Sharma et al. (2020) where the agent maximizes the mutual information between observable variables and a latent skill vector. We discuss the differences between CIC and the most closely related competence-based exploration algorithms in Appendix D.
Unsupervised Representation Learning: Much progress in unsupervised representation learning for RL has been spurred by unsupervised learning in computer vision (Chen et al., 2020; He et al., 2020; Hénaff et al., 2020; Kingma & Welling, 2013) and language (Brown et al., 2020; Devlin et al., 2019; Radford et al., 2019). In RL, the most common approach for representation learning has been by adding it as an auxiliary loss in the supervised RL setting (Jaderberg et al., 2017). More recently, a number of works have investiagted representaton learning with autoencoders (Yarats et al., 2019; Hafner et al., 2019; 2020), siamese networks (Schwarzer et al., 2021a;b; Laskin et al., 2020b; Stooke et al., 2021; Yarats et al., 2021b), and data augmentation (Laskin et al., 2020a; Yarats et al., 2021a;c).

heading: 9 CONCLUSION
text: We have introduced a new competence-based algorithm – Contrastive Intrinsic Control (CIC) – which enables more effective exploration than prior unsupervised skill discovery algorithms by explicitly encouraging diverse behavior while distilling predictable behaviors into skills with a contrastive discriminator. We showed that CIC is the first competence-based approach to achieve leading performance on URLB. We hope that this encourages further research in unsupervised skill discovery toward building more powerful exploration agents.
4The performance will, of course, be much better if we finetune the skill, but we cannot do so for zero-shot evaluation.

heading: A COMPETENCE-BASED EXPLORATION ALGORITHMS
text: The competence-based algorithms considered in this work aim to maximize I(τ ; s). The algorithms differ by ho they decompose mutual information, whether they explicitly maximize behavioral entropy, their skill space (discrete or continuous) and their intrinsic reward structure. We provide a list of common competence-based algorithms in Table 1.
Table 1: Competence-based Unsupervised Skill Discovery Algorithms
Algorithm Intrinsic Reward Decomposition Explicit maxH(τ) Skill Dim. Skill Space
SSN4HRL (Florensa et al., 2018) log qψ(z|st) H(z)−H(z|τ) No 6 discrete VIC (Gregor et al., 2017) log qψ(z|sH)) H(z)−H(z|τ) No 60 discrete VALOR (Achiam et al., 2018) log qψ(z|s1:H) H(z)−H(z|τ) No 64 discrete DIAYN (Eysenbach et al., 2019) log qψ(z|st) H(z)−H(z|τ) No 128 discrete DADS (Sharma et al., 2020) qψ(s′|z, s)− ∑ i log q(s
′|zi, s) H(τ)−H(τ |z) Yes 5 continuous VISR (Hansen et al., 2020) log qψ(z|st) H(z)−H(z|τ) No 10 continuous APS (Liu & Abbeel, 2021b) FSuccessor(s|z) +Hparticle(s) H(τ)−H(τ |z) Yes 10 continuous CIC (Ours) FCPC(s, s′|z) +Hparticle(s, s′) H(τ)−H(τ |z) Yes 64 continuous
Table 2: A list of competence-based algorithms. We describe the intrinsic reward optimized by each method and the decomposition of the mutual information utilized by the method. We also note whether the method explicitly maximizes state transition entropy. Finally, we note the maximal dimension used in each work and whether the skills are discrete or continuous. All methods prior to CIC only support small skill spaces, either because they are discrete or continuous but low-dimensional.

heading: B DEEP DETERMINISTIC POLICY GRADIENT (DDPG)
text: A DDPG is an actor-critic RL algorithm that performs off-policy gradient updates and learns a Q function Qφ(s, a) and an actor πθ(a|s). The critic is trained by satisfying the Bellman equation.
LQ(φ,D) = E(st,at,rt,st+1)∼D [( Qφ(st, at)− rt − γQφ̄(st+1, πθ(st+1) )2] . (7)
Here, φ̄ is the Polyak average of the parameters φ. As the critic minimizes the Bellman error, the actor maximizes the action-value function.
Lπ(θ,D) = Est∼D [Qφ(st, πθ(st))] . (8)

heading: C BASELINES
text: For baselines, we choose the existing set of benchmarked unsupervised RL algorithms on URLB. We provide a quick summary of each method. For more detailed descriptions of each baseline we refer the reader to URLB (Laskin et al., 2021)
Competence-based Baselines: CIC is a competence-based exploration algorithm. For baselines, we compare it to DIAYN (Eysenbach et al., 2019), SMM (Lee et al., 2019), and APS (Liu & Abbeel, 2021b). Each of these algorithms is described in Table 1. Notably, APS is a recent state-of-the-art competence-based method that is the most closely related algorithm to the CIC algorithm. CIC and APS differ in their discriminator.
Knowledge-based Baselines: For knowledge-based baselines, we compare to ICM Pathak et al. (2017), Disagreement Pathak et al. (2019), and RND Burda et al. (2019b). ICM and RND train a dynamics model and random network prediction model and define the intrinsic reward to be proportional to the prediction error. Disagreement trains an ensemble of dynamics models and defines the intrinsic reward to be proportional to the uncertainty of an ensemble.
Data-based Baselines: For data-based baselines we compare to APT (Liu & Abbeel, 2021a) and ProtoRL (Yarats et al., 2021b). Both methods use a particle estimator to estimate the state visitation entropy. ProtoRL also performs discrete contrastive clustering as in Caron et al. (2020) as an auxiliary task and uses the resulting clusters to compute the particle entropy. While ProtoRL is more effective than APT when learning from pixels, on state-based URLB APT is competitive with ProtoRL. Our method CIC is effectively a skill-conditioned APT agent with a contrastive discriminator.

heading: D RELATION TO PRIOR SKILL DISCOVERY METHODS
text: The most closely relatd prior algorithm to CIC is APS Liu & Abbeel (2021b). Both CIC and APS use the H(τ) − H(τ |z) decomposition of the mutual information and both used a particle estimator (Singh et al., 2003) to compute the state entropy as in Liu & Abbeel (2021a). The main difference between CIC and APS is the discriminator. APS uses successor features as in Hansen et al. (2020) for its discriminator while CIC uses a noise contrastive estimator. Unlike successor features, which empirically only accommodate low-dimensional continuous skill spaces (see Table 1), the noise contrastive discriminator is able to leverage higher continuous dimensional skill vectors.
The CIC discriminator is similar to the one used in DISCERN (Warde-Farley et al., 2018), a goalcondition unsupervised RL algorithm. Both methods use a contrastive discriminator by sampling negatives and computing an inner product between queries and keys. The main differences are (i) that DISCERN maximizes I(τ ; g) where g are image goal embeddings while CIC maximizes I(τ ; z) where z are abstract skill vectors; (ii) DISCERN uses the DIAYN-style decomposition I(τ ; g) = H(g) −H(g|τ) while CIC decomposes through H(τ) −H(τ |z), and (iii) DISCERN discards the H(g) term by sampling goals uniformly while CIC explicitly maximizes H(τ). While DISCERN and CIC share similarities, DISCERN operates over image goals while CIC operates over abstrac skill vectors so the two methods are not directly comparable.
Finally, another similar algorithm to CIC is DADS (Sharma et al., 2020) which also decomposes throughH(τ)−H(τ |z). While CIC uses a contrastive density estimate for the discriminator, DADS uses a maximum likelihood estimator similar to DIAYN. DADS maximizes I(s′|s, z) and estimates entropy H(s′|s) by marginalizing over z such that H(s′|s) = − log ∑ i q(s
′|s, zi) while CIC uses a particle estimator. Interestingly, the DADS intrinsic reward ri ∝ log (q(s′|s, z)/ ∑ i q(s
′|s, zi)) looks similar to the CIC objective with zero entropy, since marginalizing over z to compute entropy is similar to sampling negatives for a contrastive discriminator.

heading: E FULL CIC ALGORITHM
text: The full CIC algorithm with both pre-training and fine-tuning phases is shown in Algorithm 1. We pre-train CIC for 2M steps, and finetune it on each task for 100k steps.
Algorithm 1 Contrastive Intrinsic Control Require: Initialize all networks: encoders gψ1 and gψ2 , actor πθ , critic Qφ, replay buffer D. Require: Environment (env), M downstream tasks Tk, k ∈ [1, . . . ,M ]. Require: pre-train NPT = 2M and fine-tune NFT = 100K steps.
1: for t = 1..NPT do . Part 1: Unsupervised Pre-training 2: Sample and encode skill z ∼ p(z) and z ← gψ2(z) 3: Encode state st ← gψ1(st) and sample action at ← πθ(st, z) + where ∼ N (0, σ2) 4: Observe next state st+1 ∼ P (·|st, at) 5: Add transition to replay buffer D ← D ∪ (st, at, st+1) 6: Sample a minibatch from D, compute contrastive loss in Eq.3 and update encoders gψ1 , gψ2 , compute
CIC intrinsic reward with Eq. 6 and update actor πθ and critic Qφ 7: end for 8: for Tk ∈ [T1, . . . , TM ] do . Part 2: Supervised Fine-tuning 9: Initialize all networks with weights from pre-training phase and an empty replay buffer D.
10: for t = 1 . . . 4, 000 do 11: Take random action at ∼ N (0, 1) 12: Select skill with grid sweep over unit interval [0, 1] every 100 steps 13: Sample minibatch from D and update actor πθ and critic Qφ 14: end for 15: Fix skill z that achieved highest extrinsic reward during grid sweep. 16: for t = 4, 000 . . . NFT do 17: Encode state st ← gψ1(st) and sample action at ← πθ(st, z) + where ∼ N (0, σ2) 18: Observe next state and reward st+1, rextt ∼ P (·|st, at) 19: Add transition to replay buffer D ← D ∪ (st, at, rextt , st+1) 20: Sample minibatch from D and update actor πθ and critic Qφ. 21: end for 22: Evaluate performance of RL agent on task Tk 23: end for

heading: F HYPER-PARAMETERS
text: Baseline hyperparameters are taken from URLB Laskin et al. (2021), which were selected by performing a grid sweep over tasks and picking the best performing set of hyperparameters. Similarly, we also performed a grid sweep for CIC to pick the best performing set of hyperparameters. All hyperparameters are the same across all domains except for α which is set to α = 0.9 for Walker and Quadruped domains. Note that α = 0.9 results in equal weighing of the CPC and particle entropy terms since their absolute values are on different scales. For Jaco, we found α = 0.0 to work best, which means that only the discriminator contributes to the intrinsic reward. We hypothesize that particle entropy maximization is not important for Jaco arm because it is fixed and has no way of falling over like Walker and Quadruped, such that meaningful behaviors can be learned with the discriminator alone.

heading: G RAW NUMERICAL RESULTS
text: We provide a list of raw numerical results for finetuning CIC and baselines in Table 4.

heading: H LEARNING CURVES FOR DOWNSTREAM ADAPTATION PHASE

heading: I TOY EXAMPLE TO ILLUSTRATE THE NEED FOR LARGER SKILL SPACES
text: We illustrate the need for larger skill spaces with a gridworld example. Suppose we have an agent in a 10 × 10 sized gridworld and that we have four discrete skills at our disposal. Now let τ = s and consider how we may achieve maximal I(τ ; z) in this setting. If we decompose I(τ ; z) = H(z)−H(z|τ) then we can achieve maximalH(z) by sampling the four skills uniformly z ∼ p(z). We can achieveH(z|τ) = 0 by mapping each skill to a distinct neighboring state of the agent. Thus, our mutual information is maximized but as a result the agent only explores four out of the hundrend available states in the gridworld.
Now suppose we consider the second decomposition I(τ ; z) = H(τ) −H(τ |z). Since the agent is maximizing H(τ) it is likely to visit a diverse set of states at first. However, as soon as it learns an accurate discriminator we will haveH(τ |z) and again the skills can be mapped to neighboring states to achieve minimal conditional entropy. As a result, the skill conditioned policy will only be able to reach four out of the hundrend possible states in this gridworld. This argument is shown visually in Fig. 8.
Skill spaces that are too large can also be an issue. Consider if we had 100 skills at our disposal in the same gridworld. Then the agent could minimize the conditional entropy by mapping each skill to a unique state which would result in the agent memorizing the environment by finding a one-toone mapping between states and skills. While this is a potential issue it has not been encountered in practice yet since current competence-based methods support small skill spaces relative to the observation space of the environment.

heading: J QUALITATIVE ANALYSIS OF SKILLS
text: We provide two additional qualitative analyses of behaviors learned with the CIC algorithm. First, we take a simple pointmass setting and set the skill dimension to 1 in order to ablate the skills learned by the CIC agent in a simple setting. We sweep over different values of z and plot the behavioral flow vector field (direction in which point mass moves) in Fig.9. We find that the pointmass learns skills that produce continuous motion and that the direction of the motion changes as a function of the skill value. Near the origin the pointmass learns skills that span all directions, while near the edges the point mass learns to avoid wall collisions. Qualitatively, many behaviors are periodic.
Qualitatively, we find that methods like DIAYN that only support low dimensional skill vectors and do not explicitly incentivize diverse behaviors in their objective produce policies that map skills to a small set of static behaviors. These behaviors shown in Fig. 10 are non-trivial but also have low behavioral diversity and are not particularly useful for solving the downstream task. This observation is consistent with Zahavy et al. (2021) where the authors found that DIAYN maps to static “yoga” poses in DeepMind Control. In contrast, behaviors produce by CIC are dynamic resulting flipping, jumping, and locomotive behaviors that can then be adapted to efficiently solve downstream tasks.

heading: K OPENAI GYM VS. DEEPMIND CONTROL: HOW EARLY TERMINATION LEAKS EXTRINSIC SIGNAL
text: Prior work on unsupervised skill discovery for continuous control (Eysenbach et al., 2019; Sharma et al., 2020) was evaluated on OpenAI Gym (Brockman et al., 2016) and showed diverse exploration on Gym environments. However, Gym environment episodes terminate early when the agent loses balance, thereby leaking information about the extrinsic task (e.g. balancing or moving). However, DeepMind Control (DMC) episodes have a fixed length of 1k steps. In DMC, exploration is therefore harder since the agent needs to learn to balance without any extrinsic signal.
To evaluate whether the difference in the two environments has impact on competence-based exploration, we run DIAYN on the hopper environments from both Gym and DMC. We compare to ICM, a popular exploration baseline, and a Fixed baseline where the agent receives an intrinsic reward of 1 for each timestep and no algorithms receive extrinsic rewards. We then measure the extrinsic reward, which loosely corresponds to the diversity of behaviors learned. Our results in Fig. 11 show that indeed DIAYN is able to learn diverse behaviors in Gym but not in DMC while ICM is able to learn diverse behaviors in both environments. Interestingly, the Fixed baseline achieves the highest reward on the Gym environment by learning to stand and balance. These results further motivate us to evaluate on URLB which is built on top of DMC.

heading: L PSEUDOCODE FOR THE CONTRASTIVE DISCRIMINATOR IN CIC
text: CIC consists of two terms I(τ ; z) = H(τ)−H(τ |z) ≥ H(τ) + E[log q(τ |z)] the entropy H(τ) is estimated with a particle estimator Singh et al. (2003); Liu & Abbeel (2021a) while the discriminator q(τ |z) is estimated with a contrastive loss introduced in this work. Note that contrastive learning in CIC is different than prior vision-based contrastive learning such as CURL Laskin et al. (2020b), since we are not performing contrastive learning over augmented images but rather over state transitions and skills. The contrastive objective in CIC is used for unsupervised learning of behaviors while in CURL it is used for unsupervised learning of visual features.
We provide pseudocode for discriminator below:
1 d e f d i s c r i m i n a t o r l o s s ( s t a t e s , n e x t s t a t e s , s k i l l s , temp ) : 2 ””” 3 − s t a t e s and s k i l l s a r e sampled from r e p l a y b u f f e r 4 − s k i l l s were sampled from un i fo rm d i s t [ 0 , 1 ] d u r i n g a g e n t r o l l o u t 5 − s t a t e s / n e x t s t a t e s : dim (B , D s t a t e ) 6 − s k i l l s : dim (B , D s k i l l ) 7 ””” 8
9 t r a n s i t i o n s = c o n c a t ( s t a t e s , n e x t s t a t e s , dim =1) 10 11 que ry = s k i l l n e t ( s k i l l s ) # (B , D hidden ) −> (B , D hidden ) 12 key = t r a n s i t i o n n e t ( t r a n s i t i o n s ) # (B , 2* D s t a t e ) −> (B , D hidden ) 13 14 que ry = n o r m a l i z e ( query , dim =1) 15 key = n o r m a l i z e ( key , dim =1) 16 17 l o g i t s = matmul ( query , key . T ) / temp # (B , B) 18 19 # p o s i t i v e s a r e on d i a g o n a l , n e g a t i v e s a r e o f f d i a g o n a l 20 # f o r each s k i l l , n e g a t i v e s a r e sampled from t r a n s i t i o n s 21 # w h i l e s k i l l s a r e f i x e d 22 l o s s = c r o s s e n t r o p y ( l o g i t s ) 23 24 r e t u r n l o s s
Listing 1: CIC discriminator loss
We note that this is substantially different from prior contrastive learning works in RL such as CURL (Laskin et al., 2020b), which perform contrastive learning over images.
1 d e f c u r l l o s s ( obs , W, temp ) : 2 ””” 3 − o b s e r v a t i o n images a r e sampled from r e p l a y b u f f e r 4 − obs : dim (B , C , H, W) 5 − W: p r o j e c t i o n m a t r i x ( D hidden , D hidden ) 6 ””” 7 8 que ry = aug ( obs ) 9 key = aug ( obs )
10 11 que ry = c n n n e t ( que ry ) # (B , D hidden ) 12 key = c n n n e t ( key ) # (B , D hidden ) 13 14 l o g i t s = matmul ( matmul ( query , W) , key . T ) / temp # (B , B) 15 16 # p o s i t i v e s a r e on d i a g o n a l 17 # n e g a t i v e s a r e o f f d i a g o n a l 18 l o s s = c r o s s e n t r o p y ( l o g i t s ) 19 20 r e t u r n l o s s
Listing 2: CURL contrastive loss

heading: M ON TIGHTER ESTIMATES OF MUTUAL INFORMATION
text: In this work we have presented CIC - a new competence-based algorithm that achieves leading performance on URLB compared to prior unsupervised RL methods. We’ve shown that CIC results in a tighter lower bound on mutual information than CPC by including the entropy term.
One might wonder whether estimating the exact mutual information (MI) or maximizing the tightest lower bound thereof is really the goal for unsupervised RL. In unsupervised representation learning, state-of-the-art methods like CPC and SimCLR maximize the lower bound of MI based on Noise Contrastive Estimation (NCE). However, as proven in CPC (Oord et al., 2018) and illustrated in Poole et al. (2019) NCE is upper bounded by logN , meaning that the bound is loose when the MI is larger than logN . Nevertheless, these methods have been repeatedly shown to excel in practice. In Tschannen et al. (2020) the authors show that the effectiveness of NCE results from the inductive bias in both the choice of feature extractor architectures and the parameterization of the employed MI estimators.
We have a similar belief for unsupervised RL - that with the right parameterization and inductive bias, the MI objective will facilitate behavior learning in unsupervised RL. This is why CIC lower bounds MI with (i) the particle based entropy estimator to ensure explicit exploration and (ii) a contrastive conditional entropy estimator to leverage the power of contrastive learning to discriminate skills. As demonstrated in our experiments, CIC outperforms prior methods, showing the effectiveness of optimizing an intrinsic reward with the CIC MI estimator.

heading: N LIMITATIONS
text: While CIC achieves leading results on URLB, we would also like to address its limitations. First, in this paper we only consider MDPs (and not partially observed MDPs) where the full state is observable. We focus on MDPs because generating diverse behaviors in environments with large state spaces has been the primary bottleneck for competence-based exploration. Combining CIC with visual representation learning to scale this method to pixel-based inputs is a promising future direction for research not considered in this work. Another limitation is that our adaptation strategy to downstream tasks requires finetuning. Since we learn skills, it would be interesting to investigate alternate ways of adapting that would enable zero-shot generalization such as learning generalized reward functions during pre-training.

Review summaries:
The paper builds upon the DIAYN idea (Eysenback 2018) that an agent could develop skills in an unsupervised environment by finding a set of skills that collectively visits the whole state space but encourages each skill to cover a different subspace and later use one of these skills to simplify the learning of a downstream task. In this paper skills are learned in an unsupervised way using a mutual information based objective. The mutual information between latent states T and skill vector Z, I(T;Z), is decomposed as I(T;Z)=H(T)-H(T|Z) which the paper argues leads to explicit maximization of diversity of latent states T as well as distinct skills with focused effects by penalizing with H(T|Z). More diversity equals better exploration of more distant states leading to more interesting behaviors. The paper explains this decomposition also allows them to user higher-dimensional skill vectors that improve representational capacity and downstream performance. The paper develops a method to calculate the terms of this decomposition and formally shows it is a lower bound for the true mutual information. The latent state entropy H(T) is estimated using an unnormalized k-nearest neighbor method requiring an ad hoc scaling factor \alpha and the conditional entropy H(T|Z) is calculated using an NCE supervised neural net.  The paper illustrates the method by using their loss function to pretrain a DDPG architecture on unsupervised scenarios and then showing a benefit on downstream tasks. The proposed method, CIC, shows a larger IQM stabilized expert normalized score compared to state of the art methods.  Experiments also show that high-dimensio

The paper proposes an algorithm (Contrastive Intrinsic Control) for unsupervised skill discovery by maximizing mutual information between skill latents and state transitions. The proposed algorithm is a refinement over existing methods [2]. It uses a contrastive method to estimate conditional entropy and measures entropy on state-transitions as opposed to simply states as done in previous methods [2]. The proposed algorithm shows good performance gains compared to existing competence-based skill discovery algorithms. Further, the paper also contains a rather extensive empirical evaluation of various skill discovery algorithms on the recently proposed URLB benchmark.  

This paper tackles the problem of unsupervised pre-training of a (code-conditioned) policy to improve the performance of downstream RL tasks. In line with previous works in unsupervised skills discovery, it proposes a method, called CIC, to maximize a variational lower bound to the mutual information between the code and the visited states. The lower bound is obtained through the combination of non-parametric state entropy estimation and a contrastive predictive coding loss for the conditional entropy. The paper provides an empirical analysis of CIC over a set of continuous control domains.