S4RL: Surprisingly Simple Self-Supervision for Ofﬂine Reinforcement Learning in Robotics
Abstract: Ofﬂine reinforcement learning proposes to learn policies from large collected datasets without interacting with the physical environment.
These algorithms have made it possible to learn useful skills from data that can then be deployed in the environment in real-world settings where interactions may be costly or dangerous, such as autonomous driving or factories.
However, ofﬂine agents are unable to access the environment to collect new data, and therefore are trained on a static dataset.
In this paper, we study the effectiveness of performing data augmentations on the state space, and study 7 different augmentation schemes and how they behave with existing ofﬂine RL algorithms.
We then combine the best data performing augmentation scheme with a state-of-the-art Q-learning technique, and improve the function approximation of the Q-networks by smoothening out the learned state-action space.
We experimentally show that using this Surprisingly
Simple Self-Supervision technique in RL (S4RL), we signiﬁcantly improve over the current state-of-the-art algorithms on ofﬂine robot learning environments such as MetaWorld [1] and RoboSuite [2, 3], and benchmark datasets such as D4RL [4].
Introduction
In reinforcement learning (RL), an agent is trained to interact with its environment and learn useful skills that help with solving the given task.
However, interacting with the environment may be costly, or unsafe to do from scratch in real-world scenarios such as self-driving or industrial robotics.
Unlike directly interacting with the environment, it is much cheaper to collect and store data such that an agent can be trained on it and learn from the past experience.
In direct contrast to reinforcement learning, ofﬂine RL (or batch RL) [5] allows a setup where a behavioral policy is used to collect and store the data such that a target policy can then be used to train on the data, without any further interactions with the environments.
The behavioral policy can range from human demonstrations, random policy in the given environment, or near-optimal policies for the task.
However, learning from such demonstrations is difﬁcult since the data does not cover the full state-action space, and naive behavioral policies will not cover the state-action distribution for an optimal policy for a task.
Current ofﬂine model-free RL algorithms include learning a Q -function [6] where a parameterized neural network is trained to learn the state-action values from data [7–12].
This family of algorithms suffer from overestimating the true state-action values of data that is not in the same distribution as the ofﬂine dataset used.
Along with overestimation error, another source of error is with the function approximation of the neural networks that are typically used to parameterize the Q -functions.
This form of function approximation error may be of many forms, and recent methods have employed selfsupervised learning, causal inference [13] and data augmentations to the image observations during training, resulting in state-of-the-art results for normal reinforcement learning [14–16].
However, it is unclear to how perform such augmentations from proprioceptive information and the role of augmentation in ofﬂine RL.
In this paper we investigate the role of data augmentations from proprioceptive observations focused on ofﬂine RL.
Data augmentation also help perform better function approximation for Q -networks since it allows to smoothen out the state space by “visiting” the local regions and ensuring the learned Q -values are similar throughout, since small perturbations in the given observation should not lead to drastically different Q -values.
Our main contribution is a Surprisingly Simple Self-Supervised ofﬂine RL (S4RL) algorithm that combines studying data augmentations with a simple Q -learning method to signiﬁcantly improve the performance of ofﬂine RL algorithm.
The proposed framework is general and can be added to a number of off-the-shelf ofﬂine/batch RL algorithms for robot learning.
We present comparisons our model to other comparable self-supervised learning strategies and state-of-the-art ofﬂine RL methods on the D4RL benchmark dataset [4], which consists of continuous control, navigation and robotic control tasks collected from suboptimal and human agents.
We further experiment with two dexterous robot manipulation environments: MetaWorld [1] and RoboSuite [2, 3].
Across all evaluations, we ﬁnd that our proposed state-based data augmentation for Q -learning signiﬁcantly outperforms base ofﬂine RL algorithm as well as various competitive data augmentation baselines.
Related Work
Ofﬂine reinforcement learning: In ofﬂine RL, a static dataset of demonstrations is collected, and is used to train an agent for a given environment [5].
Popular actor-critic algorithms, such as Soft
Actor Critic (SAC) [17], tend to perform poorly on learning from ofﬂine datasets, because they are unable to generalize to out-of-distribution (OOD) data because of an overestimation bias: where the critic overestimates the values of state-action pairs not previously encountered from the collected data which leads to a brittle policy.
The convergence properties of value functions have been proven in simple settings [18]; however learning a policy using the learned value functions remains an active challenge in ofﬂine RL.
Simple algorithms like ﬁtted Q -iterations have been able to learn state-action value functions, but do not work well with sub-optimal data [19, 20].
To help solve the generalization and extrapolation problem, different ofﬂine RL algorithms have proposed to use constrained policy optimization between the target policy and the behaviour policy that was used to collect the data.
These constraints include using KL-divergence [10, 21], MMD [8] or f -divergence [22].
Some algorithms have also proposed to learn state-conditioned VAEs to minimize the extrapolation error [7, 8, 23].
Recent work by
Buckman et al.
[24] investigated using worst-case analysis to train a policy, denoted as pessimism .
Conservative Q -Learning (CQL) explicitly deals with the problem of overestimation for OOD stateaction distribution by pushing down the value of randomly sampled state-action distributions in the critic objective [25].
Learning a dynamics model from ofﬂine data has been promising [26, 27].
Recent work has also shown great promise using ofﬂine RL for real robotics tasks by learning policies that can directly be deployed on real robots to perform complex tasks [28–30].
Similar to before, such work relies on collecting large scale robotic datasets [3, 31, 32], and learning policies that can then be safely deployed after a few steps of ﬁnetuning.
Representation learning in RL: Recent work in state and pixel-based RL suggests the need to learn better representations from data usig better network architectures [33] or self-supervision [14].
Self-supervised representation learning has recently been applied to learn RL agents from pixeldata.
By using data augmentations and contrastive learning, Laskin et al.
[14] showed signiﬁcant improvements on learning from pixel data.
The need for contrastive learning was simpliﬁed by RL with Augmented Data (RAD) [16] and Data-Regularized Q -learning (DrQ) [15] as they provide a simpler alternative that used data augmentations without a contrastive objective.
More recently,
Self-Predictive Representations (SPR) optionally uses data augmentations for a self-supervision [34].
The closest work to S4RL include DrQ [15] and RAD [16] in that we utilize their method for
Q -learning over augmentations, but in contrast we focus speciﬁcally on ofﬂine RL for robotic tasks and propose augmentations from states; we also benchmark different self-supervision techniques from states.
There has also been recent works showing the effectiveness of simple data augmentation in imitation learning [35, 36].
Preliminaries
In reinforcement learning, an agent interacts with an environment to learn an optimal policy.
This is typically framed as a Markov Decision Process (MDP) which can be represented by a tuple of the form ( S , A , ρ , r , γ , ρ 0 ), where S is the state space, A is the action space, ρ ( s t +1 | s t , a t ) is the transition function given the current state and action pair, r ( s t ) is the reward model given the state, γ is the discount factor where γ ∈ [0 , 1) and ρ 0 is the initial state distribution of the MDP.
A policy, represented by π : S → A is trained to maximize the expected cumulative discounted reward in the MDP.
This can simply be formalized as: E (cid:104) (cid:80) ∞
t =0 γ t r ( s t , π ( a t | s t )) (cid:105)
Furthermore, a state-action value function, Q ( s t , a t ) , is the value of performing a given action a t given the state s t .
The Q -function is trained by minimizing the Bellman Error over Q in a step called policy evaluation
[Equation]
where Q i is the i -th step of policy evaluation.
The policy is then trained to maximize the state-action values of performing an action a t given s t in a step called policy improvement:
[Equation]
where π i is the i -th step of policy improvement.
Unlike traditional reinforcement learning, in ofﬂine RL, the goal is not to learn an optimal policy for the MDP, but rather to learn an optimal policy given the dataset.
A behaviour policy µ is used to collect a static dataset D which is then used to train a target policy π .
The policy improvement can now be stated as
[Equation]
[Equation]
) where D is the static dataset.
Since the nature of the behaviour policy µ is unknown, and can be composed of one (or more) sub-optimal policies, the RL task becomes challenging.
Since ofﬂine RL algorithms tend to generalize poorly to OOD data, the nature of µ and the optimality of µ is important.
As shown Fu et al.
[4], typical ofﬂine RL methods perform poorly when a mixture of suboptimal policies or an untrained random policy is used to collect the dataset D .
In deep reinforcement learning, both the policy and the value functions are parameterized using neural networks and trained using gradient descent.
Method
In this section we will ﬁrst consider a simple Q -learning technique based on DrQ [15], which helps combine data augmentations and learning better value functions during training by encouraging local points around the state to have similar Q -values.
Then, we introduce 7 different data augmentations strategies and apply them on the otherwise static dataset D to improve function approximation by smoothening the state-space for the Q -network.
4.1 Self-Supervision in Ofﬂine RL
We denote a data augmentation transformation as: T ( ˜ s t | s t ) where s t ∼ D , ˜ s t is the augmented state, and T is a stochastic transformation.
After producing one or multiple augmentations of a given state ˜ s t ∼ T ( s t ) , we need a method to incorporate the augmentation to encourage smoothness and consistency.
For example, [14] uses contrastive learning to “pull” the representations of two augmentations of the same state towards each other, while “pushing” two different state representations apart from each other.
We follow a similar scheme to DrQ [15], where we perform multiple augmentations of a given state, and we simple average the state-action values and target values over the different augmetations of the state.
[Equation]
The main difference between our proposed objective and the normal Q -learning objective is the mean over i different augmentations in the second term of the equation.
We augment the Bellman error in Equation 1 to simply be the mean error over the i different augmentations of the same state.
Intuitively, this will help improve the consistency of the Q -value within some perturbation ﬁeld of the current state s t , since the Bellman backups are taken over i -different views of the same state s t .
By simply averaging the state-action values and target values, we assume that the reward function is locally smooth to small perturbations in the state.
Utilizing multiple augmentations further allows the networks to learn different variations of the data; we explore the role of increasing the number of different augmentations empirically in Section 5.1.
We use the trained Q -networks to perform policy improvement using the objective in Equation 3, without augmentations.
The beneﬁts of the augmentations are distilled to the policy since the value functions are used to train the policy.
By combining such local perturbations to the states with self-supervision, we are able to learn a more robust policy that can generalize better to unseen data when deployed on robots.
An overview of the proposed method is available in Figure 1, where we disentangle the data augmentation and reinforcement learning steps to learn q -values and target values over i different augmentations of the original state.
Without loss of generality, to show local perturbations, we draw an (cid:15) -ball
over the current state s t , however different versions of augmentations are possible, as will be discussed.
4.2 Data Augmentations
In computer vision research, augmentation are commonly used as a way to obtain the same datapoint from multiple viewpoints.
Transformations such as rotation, translations, color jitters, etc. are commonly used to train neural networks.
Such transformations preserve the semantics of the image after the transformation since for example: an image of a cat rotated 15 ◦ remains an image of a cat.
However, when working from only proprioceptive information of an agent (for example: the joint angles and velocity information of an industrial robot), such transformations are semantically meaningless.
In ofﬂine RL, since an agent is unable to interact with the environment to collect new data samples, data augmentations serve as a simple technique that can allow the agent to do view different augmentations of the trajectories in the dataset.
Data augmentations from states, assumes that the output of a small transformation to an input state results in a physically realizable state in the environment.
If the augmented state is in the domain of the state space, ˜ s t ∈ S , then we consider it a valid transformation.
By performing valid augmentation stratgies, we are able to artiﬁcially increase the amount of data available during training.
Even if a transformation is physically realizable in the environment, a data augmentation strategy that is too aggressive may end up hurting the RL agent since the reward for the original state may not coincide with the reward obtained from the augmented state.
That is r ( s t ) (cid:54) =
r ( ˜ s t ) .
Therefore, one key assumption made when performing data augmentations on the states is that the reward model r ( s t ) is smooth , that is r ( s t )
≈ r
( ˜ s t ) .
Therefore the choice of T ( ˜ s t | s t ) needs to be a local transformation to perturb the state without changing the semantics.
The choice of T ( ˜ s t | s t ) is more important in ofﬂine RL than in traditional RL, since in traditional RL the agent may be able to self-correct for poor choices of transformations by being able to visit those states and correct the value functions using
Bellman backups.
A comparison is presented in Figure 2, where we see that compared to normal ofﬂine RL, adding augmentation allows for multiple paths in the policy evaluation step using Bellman backups.
By using data augmentation, we seek to exploit this smoothness property of the reward model in the MDP, which enables us to artiﬁcially visit states that may be in the state space, but not in the dataset: s t , ˜ s t ∈ S but ˜ s t / ∈ D .
Following the constraints, we consider the following transformations T ( ˜ s t | s t ) :
zero-mean Gaussian noise to the state:
˜ s t ← s t + (cid:15) , where (cid:15) ∈ N (0 , σI ) and σ is an important hyperparameter, which we will later discuss.
zero-mean Uniform noise to the state:
˜ s t ← s t + (cid:15) , where (cid:15) ∈ U ( − α, α ) and α is an important hyperparameter.
random amplitude scaling as in RAD [16]: ˜ s t ← s t ∗ (cid:15) , where (cid:15) ∈
U ( α, β ) , which preserves the signs of the states.
dimension dropout which simply zeros one random dimension in the state: ˜ s t ← s t ·where 1 is a vector of 1s with one 0 randomly sampled from a Bernoulli distribution.
This transformation preserves all-but-one intrinsic values of the current state.
state-switch where we ﬂip the value of 2 randomly selected dimensions in the state.
This naive transformation will likely break the “physical realizability” assumption, since it is possible that the two randomly selected samples are semantically dissimilar properties of a robot (such as joint angle and joint velocity).
To overcome this we hardcode the pairs of dimensions that can be switched for each environment (details in Appendix F).
state mix-up where we use mixup [37] between the current and the next state: ˜ s t ← λs t + (1 − λ ) s t +1 ,
where λ ∼ Beta ( α, α ) with α = 0 .
4 as in [37].
The next state s t + remains unchanged.
adversarial state training which we take the gradient with respect to the value function to obtain a new state.
This can be written as ˜ s t ← s t + (cid:15) ∇ s t J Q
π ( s t )) , where J Q is simply the policy evaluation update as in Equation 2, and (cid:15) constraints the size of the gradient.
The intuition behind this is to choose the direction within an (cid:15) -ball of s t where the Q -value deviates the most.
This augmentation is intuitively the most useful in state spaces with high dimensionality where random noise may be less effective [38].
Experiments
In this section, we will ﬁrst describe the dataset (D4RL [4]), and some hyperparameters and information about the experimental setup.
Then we will use S4RL to investigate the effect of different data augmentation strategies on the OpenAI Gym subset of D4RL tasks to investigate which augmentations are useful for learning.
Using the best data augmentation techniques found, we compare the algorithm to other self-supervision techniques that have been proposed for pixel-based RL, namely Contrastive
Unsupervised Reinforcement Learning (CURL) [14], and SAC+AutoEncoder (SAC+AE) where we feed the augmentations to the AutoEncoder to learn generalizable representations [39].
We add
S4RL framework to two state-of-the-art ofﬂine RL algorithms: Conservative Q -learning (CQL) [25] and Behaviour Regularized Actor Critic (BRAC) [10] to show the effectiveness over both baseline agents to show the generality of S4RL.
We add the CQL regularization to each self-supervised baseline considered, since the self-supervised baselines were considered for online RL and CQL adds a regularization term to help with overestimation.
We ﬁrst test each baseline on the full suite of D4RL tasks [4], which includes environments such as a Maze environment where an ant agent must learn locomotion and navigation skills to reach an environment goal which requires hierarchical control, Adroit domain which requires learning dextrous object manipulation for ﬁne-grained control of a robotic hand [40], Kitchen environment which simulates a Franka Panda robot to perform kitchen tasks.
We additionally experiment with more difﬁcult robotic environments: MetaWorld [1] which uses a simulated Sawyer robot and RoboSuite [2] which uses a Franka Panda robotic arm for manipulation.
We further benchmark each of the baselines on learning with limited data in Appendix
A, to investigate the effect of self-supervision when the agent has signiﬁcantly less data to train from.
Finally, we experiment with different ways to regularize Q -networks typically used in neural network training such as Dropout and Weight Decay in Appendix D and include ablation experiments investigating the number of augmentations and the role of hyperparameters in Appendix E.
Hyperparameters: For all experiments, we do not perform any hyperparamter tuning to the base
CQL agent; all agents are trained using the original hyperparameters.
Similar to DrQ, we useaugmentations for obtaining the state-action values and the target values.
We use a σ and α value of 3 × 10 − 4 for the zero-mean Gaussian and Uniform noise augmentation variant, respectively.
We use a value of 1 × 10 − 4 for (cid:15) for adversarial training; an ablation on σ and (cid:15) is available in Appendix E.
5.1 Results
Role of Data Augmentations We ﬁrst investigate different data augmentation schemes and its performance on the OpenAI Gym subset of the D4RL tasks.
We compare a base CQL agent with and without different forms of augmentation strategies, and tabulate the mean normalized performance, average normalized performance over all the tasks and relative rankings in Table 1.
We see that using zero-mean Gaussian noise ( N ), zero-mean Uniform noise ( U ), state mix-up and adversarial state training consistently outperform the the baseline CQL agent, as well as different data augmentation variants.
The average-ranking of S4RL-Adv and S4RL- N are 1.83 and 1.92 respectively, suggesting their effectiveness over a wide range of task and data distributions.
We also see that CQL+S4RL agent is able to learn useful policies given data collected from a random policy as evidenced by the performance in “walker-random” where the base CQL agent is unable to learn any meaningful policy.
We also see that the S4RL agent is able to signiﬁcantly outperform the baseline CQL agent on complex data distributions such as “-medium-replay” where the data collected is from all the data
[Table] [Table]
collected while training a policy in the environment.
Therefore the data split consists of data that ranges from a completely untrained policy (random policy), to a “medium” trained policy.
It is also important to look at the different augmentation techniques that do not help policy learning.
Techniques that hurt the performance and perform worse than the baseline CQL agent include
Dimension-Dropout and State-Switch.
Both techniques are inspired by popular computer vision data augmentation algorithms, mainly MixMatch [41] and CutMix [42].
Since both techniques perform element-wise operations, it is likely that they omit important information about the state of the robot such as joint velocity.
Without such information, it is possible that the value function is unable to reason about the environment which results in poor value estimates.
[Figure]
Comparison to other self-supervision techniques Following insights from Table 1, we choose three data augmentation approaches, namely S4RL- N , S4RL-MixUp and S4RL-Adv, to compare to other self-supervision techniques.
We present the results over all the different tasks in D4RL in
Table 2 using base CQL [25] and BRAC agents [10].
Despite its simplicity, we continuously observe that +S4RL- N and +S4RL-adv agents are able to signiﬁcantly outperform the baselines on almost all tasks, and is comparable to the best in the others for both ofﬂine RL algorithms.
We speciﬁcally note that +S4RL-Adv signiﬁcantly outperforms all other baselines when the state-dimensionality is high, such as the dexterous manipulation environment of Adriot and on Franka robot.
In challenging environments that require hierarchical control such as the AntMaze environments, we see that
the
S4RL agent continues to be the best performing agent.
Interestingly, on certain environments namely “pen-cloned”, “pen-human”, “hammer-human” and “door-human” the BRAC+S4RL agent is able to learn some useful skills, whereas the base CQL agent performs poorly.
This further highlights the usefulness and generality of performing state-based augmentations for ofﬂine reinforcement learning.
Dexterous Manipulation Environments Finally, we perform more experiments in the robotic domain using the MetaWorld [1] and RoboSuite environments on difﬁcult manipulation tasks.
For
MetaWorld, we train a SAC agent [17] for 1M steps and collect 1000 trajectories of 200 episode length.
For RoboSuite, we collect data at 3 different instances during training to make the data distribution more complex.
More details on the data collection is available in Appendix I.
The results are presented in Figure 4.
Similar to before we see signiﬁcant improvements over the baseline in each of the 7 environments over both domains.
The proposed S4RL-Adv agent is the only agent that is able to outperform the trained behaviour policy on 3 of the 5 MetaWorld tasks, while continuing to signiﬁcantly outperform the baselines by as much as 3 times, as in the case of “push-v1” and “pick-and-place-can”.
Full numerical results can be found in Appendix C
Conclusion
In this paper, we present S4RL: a Surprisingly Simple Self-Supervised ofﬂine RL method that uses data augmentations to improve the function approximation for Q -learning algorithms in ofﬂine
RL.
S4RL offers simplicity and ease of implementation, and can be added to any ofﬂine agent that requries Q -learning.
We ﬁrst compare and benchmark the effectiveness of 7 different data augmentation strategies from states in ofﬂine RL and then use the insights to compare against different self-supervised representation learning algorithms that have been proposed for pixel-based online RL.
We observe signiﬁcant performance gains over the benchmark D4RL dataset [4] and on more dexterous robot manipulation environments.
We observe signiﬁcant performance gains which make ofﬂine policy learning increasingly more competitive and help robot learning from only past data.
Interesting future extension of this work can seek to use the suggested augmentation schemes to build better self-supervised learning algorithms. Acknowledgments
Animesh Garg is supported by CIFAR AI Chair, NSERC Discovery Grant RGPIN-2021-04392 and
DGECR-2021-00368, University of Toronto Engineering Xseed Grants.
Ajay Mandlekar acknowledges the support of the Department of Defense (DoD) through the NDSEG program.
The authors would also thank Vector Institute for computing support.
The authors would also like to thank Aviral
Kumar for his help setting up the CQL experiments and for helpful discussions regarding the paper.