Contrastive Learning as Goal-Conditioned Reinforcement Learning
Anonymous Author(s)
AffiliationAddress email
Abstract
In reinforcement learning (RL), it is easier to solve a task if given a good representation.
While deep RL should automatically acquire such good representations,prior work often finds that learning representations in an end-to-end fashion isunstable and instead equip RL algorithms with additional representation learningparts (e.g., auxiliary losses, data augmentation).
How can we design RL algorithms that directly acquire good representations?
In this paper, instead of addingrepresentation learning parts to an existing RL algorithm, we show (contrastive)representation learning methods can be cast as RL algorithms in their own right.
To do this, we build upon prior work and apply contrastive representation learningto action-labeled trajectories, in such a way that the (inner product of) learnedrepresentations exactly corresponds to a goal-conditioned value function.
Weuse this idea to reinterpret a prior RL method as performing contrastive learning,and then use the idea to propose a much simpler method that achieves similarperformance.
Across a range of goal-conditioned RL tasks, we demonstrate thatcontrastive RL methods achieve higher success rates than prior non-contrastivemethods, including in the offline RL setting.
We also show that contrastive RLoutperforms prior methods on image-based tasks, without using data augmentationor auxiliary objectives.
Introduction
Representation learning is an integral part of reinforcement learning (RL 1 ) algorithms.
While suchrepresentations might emerge from end-to-end training [7, 79, 118, 125], prior work has found itnecessary to equip RL algorithms with perception-specific loss functions [32, 44, 71, 89, 91, 100,115, 139] or data augmentations [69, 73, 115, 117], effectively decoupling the representation learningproblem from the reinforcement learning problem.
Given what prior work has shown about RLin the presence of function approximation and state aliasing [2, 134, 137], it is not surprising thatend-to-end learning of representations is fragile [69, 73]: an algorithm needs good representationsto drive the learning of the RL algorithm, but the RL algorithm needs to drive the learning of goodrepresentations.
So, can we design RL algorithms that do learn good representations, without theneed for auxiliary perception losses?
Rather than using a reinforcement learning algorithm to also solve a representation learning problem,we will use a representation learning algorithm to also solve certain types of reinforcement learningproblems, namely goal-conditioned RL.
Goal-conditioned RL is widely studied [6, 15, 22, 62,80, 119], and intriguing from a representation learning perspective because it can be done in anentirely self-supervised manner, without manually-specified reward functions.
We will focus oncontrastive (representation) learning methods, using observations from the same trajectory (as done
[Figure]
: "Is state or state?"
state-
[Figure]
encoder, .
goal encoder,
[Figure]
in prior work [95, 108]) while also including actions as an additional input (See Fig. 1).
Intuitively,contrastive learning then resembles a goal-conditioned value function: nearby states have similarrepresentations and unreachable states have dissimilar representations.
We make this connectionprecise, showing that sampling positive pairs using the discounted state occupancy measure results inlearning representations whose inner product exactly corresponds to a value function.
In this paper, we show how contrastive representation learning can be used to perform goalconditioned RL.
We formally relate the learned representations to reward maximization, showingthat the inner product between representations corresponds to a value function.
This framework ofcontrastive RL generalizes prior methods, such as C-learning [29], and suggests new goal-conditioned
RL algorithms.
One new method achieves performance similar to prior methods but is simpler;another method consistently outperforms the prior methods.
On goal-conditioned RL tasks withimage observations, contrastive RL methods outperform prior methods that employ data augmentationand auxiliary objectives, and do so without data augmentation or auxiliary objectives.
In the offlinesetting, contrastive RL can outperform prior methods on benchmark goal-reaching tasks, sometimesby a wide margin.
Related Work
This paper will draw a connection between RL and contrastive representation learning, buildingupon a long line of contrastive learning methods in NLP and computer vision, and deep metriclearning [17, 53, 54, 54, 56, 77, 84, 86, 87, 94, 95, 107, 108, 112, 121, 128, 131].
Contrastive learningmethods learn representations such that similar (“positive”) examples have similar representationsand dissimilar (“negative”) examples have dissimilar representations.
2 While most methods generatethe “positive” examples via data augmentation, some methods generate similar examples usingdifferent camera viewpoints of the same scene [108, 121], or by sampling examples that occur closein time within time series data [4, 95, 108, 117].
Our analysis will focus on this latter strategy, as thedependence on time will allow us to draw a precise relationship with the time dependence in RL.
Deep RL algorithms promise to automatically learn good representations, in an end-to-end fashion.
However, prior work has found it challenging to uphold this promise [7, 79, 118, 125], promptingmany prior methods to employ separate objectives for representation learning and RL [32, 44, 71,89, 91, 100, 115, 117, 139].
Many prior methods choose a representation learning objectives thatreconstruct the input state [32, 47, 49, 50, 71, 91, 93, 140] while others use contrastive representationlearning methods [89, 95, 110, 115, 117].
Unlike these prior methods, we will not use a separaterepresentation learning objective, but instead use the same objective for both representation learningand reinforcement learning.
Some prior RL methods have also used contrastive learning to acquire reward functions [14, 20, 33, 38, 63, 67, 92, 132, 133, 144], often in imitation learning settings [37,55].
In contrast, we will use contrastive learning to directly acquire a value function, which (unlike areward function) can be used directly to take actions, without any additional RL.
This paper will focus on goal-conditioned RL problems, a problem prior work has approached usingtemporal difference learning [6, 29, 62, 80, 102, 105], conditional imitation learning [22, 41, 83, 104,119], model-based methods [23, 106], hierarchical RL [90], and planning-based methods [30, 93,104, 114].
The problems of automatically sampling goals and exploration [24, 35, 85, 98, 142] areorthogonal to this work.
Like prior work, we will parametrize the value function as an inner productbetween learned representations [34, 58, 105].
Unlike these prior methods, we will learn a valuefunction directly via contrastive learning, without using reward functions or TD learning.
Our analysis will be most similar to prior methods [11, 15, 29, 102] that view goal-conditioned RLas a data-driven problem, rather than as a reward-maximization problem.
Many of these methodsemploy hindsight relabeling [6, 26, 62, 78], wherein experience is relabeled with an outcome thatoccurred in the future.
Whereas hindsight relabeling is typically viewed as a trick to add on top ofan RL algorithm, this paper can roughly be interpreted as showing that the hindsight relabeling is astandalone RL algorithm.
Many goal-conditioned methods learn a value function that captures thesimilarity between two states [29, 62, 91, 124].
Such distance functions are structurally similar to thecritic function learned for contrastive learning, a connection we make precisely in Sec. 4.
In fact, ouranalysis shows that C-learning [29] is already performing contrastive learning, and our experimentsshow that alternative contrastive RL methods can be much simpler and achieve higher performance.
Prior work has studied how representations related to reward functions using the framework ofuniversal value functions [12, 105] and successor features [9, 52, 81].
While these methods typicallyrequire additional supervision to drive representation learning (manually-specified reward functionsor features), our method is more similar to prior work that estimates the discounted state occupancymeasure as an inner product between learned representations [11, 130].
While these methods usetemporal difference learning, ours is akin to Monte Carlo learning.
While Monte Carlo learning isoften (but not always [23]) perceived as less sampling efficient, our experiments find that our approachcan be as sample efficient as TD methods.
Other prior work has focused on learning representationsthat can be used for planning [59, 82, 103, 104, 127].
Our method will learn representations usingan objective similar to prior work [104, 108], but makes the key observation that the representationalready encodes a value function: no additional planning or RL is necessary to choose actions.
Please see Appendix A for a discussion of how our work relates to unsupervised skill learning.
Preliminaries
Goal-conditioned reinforcement learning.
The goal-conditioned RL problem is defined by states 102 s t ∈ S , actions a t , an initial state distribution p 0 ( s ) , the dynamics p ( s t +1 | s t , a t ) , a distribution 103 over goals p g ( s g ) , and a reward function r g ( s, a ) for each goal.
This problem is equivalent to a 104 multi-task RL [5, 45, 120, 129, 138], where tasks correspond to reaching goals states.
Followingprior work [11, 15, 29, 102], we define the reward as the probability (density) of reaching the goal atthe next time step:
[Equation]
This reward function is appealing because it avoids the need for a human user to specify a distance 108 metric (unlike, e.g., [6]).
Even though our method will not estimate the reward function, we will stilluse the reward function for analysis.
For a goal-conditioned policy π ( a | s, s g ) , we use π ( τ | s g ) todenote the probability of sampling an infinite-length trajectory τ =
( s 0 , a 0 , s 1 , a 1 , · · · ) .
We defined 111 the expected reward objective and Q-function as
[Equation]
Intuitively, this objective corresponds to sampling a goal s g and then optimizing the policy to go to 113 that goal and stay there.
Finally, we define the discounted state occupancy measure as [55, 141]
[Equation]
where p πt ( s ) is the probability density over states that policy π visits after t steps.
Sampling from thediscounted state occupancy measure is easy: first sample a time offset from a geometric distribution( t ∼ G EOM (1 − γ ) ), and then look at what state the policy visits after exactly t steps.
We will uses t + to denote states sampled from the discounted state occupancy measure.
Because our method willcombine experience collected from multiple policies, we also define the average stationary distributionas p π ( ·|· ) ( s t + = s | s, a ) ≜ (cid:82) p π ( ·|· ,s g ) ( s t
+ = s | s, a ) p
π ( s g | s, a ) ds g , where p π ( s g | s, a ) is theprobability of the commanded goal given the current state-action pair.
This stationary distribution isequivalent to that of the policy π ( a | s ) ≜ (cid:82) π ( a | s, s g )
p π ( s g | s ) ds g
Contrastive representation learning.
Contrastive representation learning methods [17, 46, 53, 54, 123 61, 77, 84, 86, 87, 121, 123, 128] take as input pairs of positive and negative examples, and learnrepresentations so that positive pairs have similar representations and negative pairs have dissimilar 125 representations.
We use ( u, v ) to denote an input pair (e.g., u is an image and v is an augmentedversion of that image).
Positive examples are sampled from a joint distribution p ( u, v ) while negative 127 examples are sampled from the product of marginal distributions, p ( u ) p ( v ) .
We will use an objectivebased on binary classification [77, 86, 87, 94].
Let f ( u, v ) =
ϕ ( u ) T ψ ( v ) be the similarity betweenthe representations of u and v .
We will call f the critic function 4 and note that its range is ( −∞ , ∞ ) .
We will use NCE-binary [84] objective (also known as InfoMAX [54]):
[Equation]
[Table]
Contrastive Learning as an RL Algorithm
This section shows how to use contrastive representation to directly perform goal-conditioned RL.
The key idea (Lemma 4.1) is that contrastive learning estimates the Q-function for a certain policyand reward function.
To prove this result, we relate the Q-function to the state occupancy measure(Sec. 4.1) and then relate the optimal critic function to the state occupancy measure (Sec. 4.2).
This result allows us to propose a new algorithm for goal-conditioned RL based on contrastivelearning.
Unlike prior work, this algorithm is not adding contrastive learning on top of an existing RLalgorithm.
This framework generalizes C-learning [29], offering a cogent explanation for its goodperformance while also suggesting new methods that are simpler and can achieve higher performance.
4.1 Relating the Q-function to probabilities
This section sets the stage for the main results of this section by providing a probabilistic perspectivegoal-conditioned RL.
The expected reward objective and associated Q-function in (Eq. 2) canequivalently be expressed as the probability (density) of reaching a goal in the future:
Proposition 1 (rewards → probabilities) .
The Q-function for the goal-conditioned reward functionr g (Eq. 1) is equivalent to the probability of state s g under the discounted state occupancy measure:
[Equation]
The proof is in Appendix B. Translating rewards into probabilities not only makes it easier to analyzethe goal-conditioned problem, but also means that any method for estimating probabilities (e.g.,contrastive learning) can be turned into a method for estimating this Q-function.
4.2 Contrastive Learning Estimates a Q-Function
We will use contrastive learning to learn a value function by carefully choosing the inputs u and v .
The first input, u , will correspond to a state-action pair, u = ( s t , a t ) ∼ p ( s, a ) .
In practice, thesepairs are sampled from the replay buffer.
Including the actions in the input is important because it will 154 allow us to determine which actions to take to reach a desired future state.
The second variable, v , is afuture state, v = s f .
For the “positive” training pairs, the future state is sampled from the discountedstate occupancy measure, s f ∼ p π ( ·|· ) ( s t + | s t , a t ) .
For the “negative” training pairs, we sample a future state from a random state-action pair: s f ∼ p ( s t + ) ≜ (cid:82) p π ( ·|· ) ( s t + | s, a ) p ( s, a ) dsda .
Withthese inputs, the contrastive learning objective (Eq. 4) can be written as
[Equation]
where L ( s, a, s + f , s − f ) ≜ log σ ( f ( s, a, s + f ) (cid:124) (cid:123)(cid:122) (cid:125)
ϕ
( s,a ) T ψ ( s + f ) )
+ log(1 − σ ( f ( s, a, s − f ) (cid:124) (cid:123)(cid:122) (cid:125) ϕ
( s
,a ) T ψ ( s − f ) )) .
Intuitively, the critic function f ( u = ( s t , a t ) , v = s f ) now tells us the correlation between the currentstate-action pair and future outcomes, analogous to a Q-function.
We therefore can use the criticfunction in the same way as actor-critic RL algorithms [66], figuring which actions lead to the desiredoutcome.
Because the Bayes-optimal critic function is a function of the state occupancy measure [84],f ∗ ( s, a, s g ) = log (cid:16) p π
[Equation]
|· )
[Equation]
s t
+ = s g
| s,a ) p ( s g ) (cid:17) , it can be used to express the Q-function:
Lemma 4.1.
The critic function that optimizes Eq.
6 is a Q-function for the goal-conditioned rewardfunction (Eq. 1), up to a multiplicative constant
[Equation]
The critic function can be viewed as an unnormalized density model, where p ( s g ) is the partitionfunction.
Much of the appeal of contrastive learning is it avoids estimating the partition function [46],which can be challenging; in the RL setting, it will turn out that this constant can be ignored whenselecting actions.
Our experiments show that learning a normalized density model works well whens g is low-dimensional, but struggles to solve higher-dimensional tasks.
This lemma relates the critic function to Q π ( ·|· ) s f ( s, a ) , not Q π ( ·|· ,s f [Equation] s f ( s, a ) .
The underlying reason isthat the critic function combines together experience collected when commanding different goals.
Prior goal-conditioned behavioral cloning methods [22, 41, 83, 119] perform similar sharing, but donot analyze the relationship between the learned policies and Q functions.
Sec.
4.5 shows that thiscritic can be used as the basis for a convergent RL algorithm, under some assumptions.
4.3 Learning the Goal-Conditioned Policy
The learned critic function not only tells us the likelihood of future states, but also tells us how 178 different actions change the likelihood of a state occurring in the future.
Thus, to learn a policy forreaching a goal state, we choose the actions that make that state most likely to occur in the future:
[Equation]
The approximation above reflects errors in learning the optimal critic, and will allow us to prove thatthis policy loss corresponds to policy improvement in Sec.
4.5, under some assumptions.
In practice, we parametrize the goal-conditioned policy as a neural network that takes as input thestate and goal and outputs a distribution over actions.
The actor loss (Eq. 7) is computed by samplingstates and random goals from the replay buffer, sampling actions from the policy, and then takinggradients on the policy using a reparametrization gradient.
On tasks with image observations, we addan action entropy term to the policy objective.
4.4 A Complete Goal-Conditioned RL Algorithm
The complete algorithm alternates between fitting the critic function using contrastive learning,updating the policy using Eq. 7, and collecting more data.
Alg.
1 provides a JAX [13] implementationof the actor and critic losses.
Note that the critic is parameterized as an inner product between a representation of the state-action pair, and a representation of the goal state:
f
( s, a, s g ) =
ϕ ( s, a ) T ψ ( s g ) .
This parametrization allows for efficient computation, as we can compute the goal representationsjust once, and use them both in the positive pairs and the negative pairs.
While this is commonpractice in representation learning, it is not exploited by most goal-conditioned RL algorithms.
Werefer to this method as contrastive RL (NCE) .
In Appendix C, we derive a variant of this method( contrastive RL (CPC) ) that uses the infoNCE bound on mutual information.
Contrastive RL (NCE) is an on-policy algorithm because it only estimates the Q-function for thepolicy that collected the data.
However, in practice we take as many gradient steps on each transition binary cross_entropy def critic_loss(states, actions, future_states): sa_repr = sa_encoder(states, actions) # (batch_dim, repr_dim) g_repr = g_encoder(future_states) # (batch_dim, repr_dim) logits =
einsum('ik,jk->ij', sa_repr, g_repr) # <sa_repr[i], g_repr[j]> for all i,j return sigmoid_binary_cross_entropy(logits=logits, labels=eye(batch_size))
def actor_loss(states, goals): actions =
policy.sample(states, goal=goals) # (batch_size, action_dim)
sa_repr = sa_encoder(states, actions) # (batch_dim, repr_dim) g_repr
= g_encoder(goals) # (batch_dim, repr_dim) logits =
einsum('ik,ik->i', sa_repr, g_repr) # <sa_repr[i], g_repr[i]> return -1.0 * logits as standard off-policy RL algorithms [40, 48].
Please see Appendix E for full implementation details.
We will also release an efficient implementation based on ACME [57] and JAX [13].
On a single
TPUv2, training proceeds at 1100 batchessec for state-based tasks and 105 batchessec for image-based tasks; forcomparison, our implementation of DrQ on the same hardware setup runs at 28 batches sec ( 3 . 9 × slower).
Architectures and hyperparameters are described in Appendix E.[-
-]
4.5 Convergence Guarantees
In general, providing convergence guarantees for methods that perform relabeling is challenging.
Mostprior work offers no guarantees [6, 22, 23] or guarantees under only restrictive assumptions [41, 119].
To prove that contrastive RL converges, we will introduce an additional filtering step into the method, 208 throwing away some training examples.
Precisely, we exclude training examples ( s, a, s f ) if theprobability of the corresponding trajectory τ i : j = ( s i , a i , s i +1 , a i +1 , · · · , s j , a j ) sampled fromπ ( τ | s g ) under the commanded goal s g is very different from the trajectory’s probability under the 211 actually-reached goal s j :
[Equation]
While this modification is necessary to prove convergence, ablation experiments in Appendix Fig. 13show that the filtering step can actually hurt performance in practice, so we do not include thisfiltering step in the experiments in the main text.
We can now prove that contrastive RL performsapproximate policy improvement.
Lemma 4.2 (Approximate policy improvement) .
Assume that states and actions are tabular and 217 assume that the critic is Bayes-optimal.
Let π ′ ( a | s, s g be the goal-conditioned policy obtainedafter one iteration of contrastive RL with a filtering parameter of ϵ . Then this policy achieves higher 219 rewards than the initial goal-conditioned policy: [Equation] for all goals
[Equation]
The proof is in Appendix B.
This result shows that performing contrastive RL on a static dataset resultsin one step of approximate policy improvement.
Re-collecting data and then applying contrastive RLover and over again corresponds to approximate policy improvement (see [10, Lemma 6.2]).
In summary, we have shown that applying contrastive learning to a particular choice of inputsresults in an RL algorithm, one that learns a Q-function and (under some assumptions)
convergesto the reward-maximizing policy.
Contrastive RL (NCE) is simple: it does not require multiple
Q-values [40], target Q networks [88], data augmentation [69, 73], or auxiliary objectives [115, 136]. [Figure]
4.6 C-learning as Contrastive Learning
C-learning [29] is a special case of contrastive RL: it learns a critic function to distinguish futuregoals from random goals.
Compared with contrastive RL (NCE), C-learning learns the classifierusing temporal difference learning.
6 Viewing C-learning as a special case of contrastive RL suggeststhat contrastive RL algorithms might be implemented in a variety of different ways, each with relativemerits.
For example, contrastive RL (NCE) is much simpler than C-learning and tends to performa bit better.
Appendix D introduces another member of the contrastive RL family ( contrastive RL(NCE + C-learning) )
that tends to yield the best performance .
Experiments
Our experiments use goal-conditioned RL problems to compare contrastive RL algorithms to priornon-contrastive methods, including those that use data augmentation and auxiliary objectives.
Wethen compare different members of the contrastive RL family, and show how contrastive RL canbe effectively applied to the offline RL setting.
For space, the offline RL results are provided in
Appendix F.2. Appendices E, F, and G contains experiments, visualizations, and failed experiments.
5.1 Comparing to prior goal-conditioned RL methods
Baselines.
We compare to three baselines.
“HER” [80] is a goal-conditioned RL method thatuses hindsight relabeling [6] with a high-performance actor-critic algorithm (TD3).
This baselineis representative of a large class of prior work that uses hindsight relabeling [6, 76, 101, 105].
Likecontrastive RL, this baseline does not assume access to a reward function.
The second baseline isgoal-conditioned behavioral cloning (“GCBC”)
[16, 22, 25, 41, 83, 96, 116, 119], which trains apolicy to reach goal s g by performing behavioral cloning on trajectories that reach state s g .
GCBCis a simple method that achieves excellent results [16, 25] and has the same inputs as our method( ( s, a, s f ) triplets).
The third baseline is a model-based approach that fits a density model to the futurestate distribution p π ( ·|· ) ( s t + | s, a ) and trains a goal-conditioned policy to maximize the probabilityof the commanded goal.
This baseline is similar successor representations [21] and prior multi-stepmodels [23, 60].
Both contrastive RL (Alg. 1) and this model-based approach encode the future statedistribution, but the output dimension of this model-based method depends on the state dimension.
We therefore expect this approach to excel in low-dimensional settings but struggle on image-basedtasks.
Where possible, we use the same hyperparameters for all methods.
We will include additionalrepresentation learning baselines when studying representations in the subsequent section.
2 1e 0.
s u cc e ss r a t e fetch reach    environment steps 1e sawyer push 0.
1.01e fetch push  41e sawyer bin contrastive RL (NCE)
TD3+HER
TD3+HER + DrQ TD3+HER + AE TD3+HER + CURL Tasks.
We compare to a suite of goalconditioned tasks, mostly taken from priorwork.
Four standard manipulation tasks includefetch reach and fetch push from Plappertet al.
[97] and sawyer push and sawyer binfrom Yu et al.
We evaluate these tasksboth with state-based observations and (unlikemost prior work) image-based observations.
The sawyer bin task poses an exploration challenge,as the agent must learn to pick up an object from one bin and place it at a goal location in anotherbin; the agent does not receive any reward shaping or demonstrations.
We include two navigationtasks: point Spiral11x11 is a 2D maze task with image observations and ant umaze [36] isa 111-dimensional locomotion task that presents a challenging low-level control problem.
Wherepossible, we use the same initial state distribution, goal distribution, observations, and definition ofsuccess as prior work.
Goals have the same dimension as the states, with one exception: on the antumaze task, we used the global XY position as the goal.
We illustrate three of the tasks to the right.
The agent does not have access to any ground truth reward function in any of these tasks.
We report results in Fig.
2, using five random seeds for each experiment and plotting the mean andstandard deviation across those random seeds.
On the state-based tasks (Fig. 2a), most methods solvethe easiest task ( fetch reach ) while only our method solves the most challenging task ( sawyerbin ).
Our method also outperforms all prior methods on the two pushing tasks.
The model-basedbaseline performs best on the ant umaze task, likely because learning a model is relatively easywhen the goal is lower-dimensional (just the XY location).
On the image-based tasks (Fig.
2b),most methods make progress on the two easiest tasks ( fetch reach and point Spiral11x11 );our method outperforms the baselines on the three more challenging tasks.
Of particular note is thesuccess on sawyer push and sawyer bin : while the success rate of our method remains below50%, no baselines make any progress on learning these tasks.
Taken together, these results suggestthat contrastive RL (NCE) is a competitive goal-conditioned RL algorithm.
5.2 Comparing to prior representation learning methods
We hypothesize that contrastive RL may automatically learn good representations.
To test thishypothesis, we compare contrastive RL (NCE) to techniques proposed by prior work for representationlearning.
These include data augmentation [69, 73, 135] (“DrQ”) and auxiliary objectives based onan autoencoder [32, 91, 93, 136] (“AE”) and a contrastive learning objective (“CURL”) that generatespositive examples using data augmentation, similar to prior work [89, 115, 117].
Because prior workhas demonstrated these techniques in combination with actor-critic RL algorithms, we will use thesetechniques in combination with the actor-critic baseline from the previous section (“TD3 + HER”).
While contrastive RL (NCE) resembles a contrastive representation learning method, it does notinclude any data augmentation or auxiliary representation learning objectives.
We show results in Fig.
4, with error bars again showing the mean and standard deviation across5 random seeds.
While adding the autoencoder improves the baseline on the fetch reach andadding DrQ improves the baseline on the sawyer push , contrastive RL (NCE) outperforms theprior methods on all tasks.
Unlike these methods, contrastive RL does not use auxiliary objectivesor additional domain knowledge in the form of image-appropriate data augmentations. These [Figure]
allowed us to identify algorithms that are much simpler
[Figure]
contrastive RL (NCE)) and that consistently achieve higher performance (contrastive RL
C experiments do not show that representation learning is never useful, and do not show that contrastive
RL cannot be improved with additional representation learning machinery.
Rather, they show thatdesigning RL algorithms that structurally resemble contrastive representation learning yields biggerimprovements than simply adding representation learning tricks on top of existing RL algorithms.
5.3 Probing the dimensions of contrastive RL
Up to now, we have focused on the specific instantiation of contrastive RL spelled out in Alg. 1.
However, there is a whole family of RL algorithms with contrastive characteristics.
C-learning is acontrastive RL algorithm that uses temporal difference learning (Sec. 4.6).
Contrastive RL (CPC) isa variant of Alg.
1 based on the infoNCE objective [95] that we derive in Appendix C Contrastive
RL (NCE + C-learning) is a variant that combines C-learning with Alg.
D (see Appendix D.).
Theaim of these experiments are to study whether generalizing C-learning to a family of contrastive RLalgorithms was useful: do the simpler methods achieve similar performance, and do other methodsachieve better performance?
We present results in Fig.
5, again plotting the mean and standard deviation across five randomseeds.
Contrastive RL (CPC) outperforms contrastive RL (NCE) on three, suggesting that swappingone mutual information estimator for another can sometimes improve performance, though bothestimators can be effective.
C-learning outperforms contrastive RL (NCE) on three tasks but performsworse on other tasks.
Contrastive RL (NCE + C-learning) consistently ranks among the best methods.
These experiments demonstrate that the prior contrastive RL method, C-learning [29], achieves goodresults on most tasks; generalizing C-learning to a family of contrastive RL algorithms resulting innew algorithms that achieve higher performance and can be much simpler.
Conclusion
In this paper, we showed how contrastive representation learning can be used for goal-conditioned RL.
This connection not only lets us re-interpret a prior RL method as performing contrastive learning,but also suggests a family of contrastive RL methods, which includes simpler algorithms, as wellas algorithms that attain better overall performance.
While this paper might be construed to implythat RL is more or less important than representation learning [72, 75, 111, 113], we have a differenttakeaway: that it may be enough to build RL algorithms that look like representation learning.
One limitation of this work is that it looks only at the goal-conditioned RL problems.
How thesemethods might be applied to arbitrary RL problems remains an open problem, though we note thatrecent algorithms for this setting [28] already bear a resemblance to contrastive RL.
Whether the richset of ideas from contrastive learning might be used to construct even better RL algorithms likewiseremains an open question.
Checklist
For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s
contributions and scope?
[Yes] The main claims are that (1) contrastive learning can be
used to learn a Q-function (Proof in Appendix B) and that (2) contrastive RL methodscan outperform non-contrastive RL algorithms on goal-conditioned RL tasks (results
in Fig. 2).
(b) Did you describe the limitations of your work?
[Yes] See Sec. 6.
(c) Did you discuss any potential negative societal impacts of your work?
[No] While RL
broadly might be used for applications with both positive and negative outcomes, ouralgorithmic contributions are not tied to any particular application.
(d) Have you read the ethics review guidelines and ensured that your paper conforms to
them?
[Yes]
If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results?
[Yes]
(b) Did you include complete proofs of all theoretical results?
[Yes] See Appendix B3.
If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main ex- perimental results (either in the supplemental material or as a URL)?
[No] We have
included all experimental details in Appendix E; code will be released upon acceptance.
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
[Yes] See Appendix E.
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[Yes] All figures show 5 random seeds, witht error bars corresponding to the mean and standard deviation across these seeds.
(d) Did you include the total amount of compute and the type of resources used (e.g., type
of GPUs, internal cluster, or cloud provider)?
[Yes] Sec. 4.4 describes the training
speed on one TPUv2.
If you are using existing assets (e g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators?
[N/A]
(b) Did you mention the license of the assets?
[N/A]
(c) Did you include any new assets either in the supplemental material or as a URL?
[N/A]
(d) Did you discuss whether and how consent was obtained from people whose data you’re
using/curating?
[N/A]
(e) Did you discuss whether the data you are using/curating contains personally identifiable
information or offensive content?
[N/A]
If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if
applicable?
[N/A]
(b) Did you describe any potential participant risks, with links to Institutional Review
Board (IRB) approvals, if applicable?
[N/A]
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]