S4RL: Surprisingly Simple Self-Supervision for Offline Reinforcement Learning
Samarth Sinha, Ajay Mandlekar, Animesh Garg
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, offline RL (or batch RL) 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 a difficult task 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 offline model-free RL algorithms include learning a -function where a parameterized neural network is trained to learn the state-action values from data . This family of algorithms suffer from overestimating the true state-action values of data that is not in the same distribution as the offline 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 -functions. Since the state-action distribution is static during training, the neural networks may overfit the data, further resulting in poor generalization when deployed to real-world settings. To discourage overfitting in neural networks, recent pixel-based methods have been proposed to utilize data augmentation to the image observations, resulting in state-of-the-art results for normal reinforcement learning . However, it is unclear to how perform such augmentations from proprioceptive information and the role of augmentation in offline RL. In this paper we investigate the role of data augmentations from proprioceptive observations focused on offline RL. Data augmentation also help perform better function approximation for -networks since it allows to smoothen out the state space by “visiting” the local regions and ensuring the learned -values are similar throughout, since small perturbations in the given observation should not lead to drastically different -values.
Our main contribution is a Surprisingly Simple Self-Supervised offline RL (S4RL) algorithm that combines studying data augmentations with a simple -learning method to significantly improve the performance of offline RL algorithm. The proposed framework is general and can be added to a number of off-the-shelf offline/batch RL algorithms for robot learning. We present comparisons our model to other comparable self-supervised learning strategies and state-of-the-art offline RL methods on the D4RL benchmark dataset , 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 and RoboSuite . Across all evaluations, we find that our proposed state-based data augmentation for -learning significantly outperforms base offline RL algorithm as well as various competitive data augmentation baselines.
Related Work
Offline reinforcement learning: In offline RL, a static dataset of demonstrations is collected, and is used to train an agent for a given environment. Popular actor-critic algorithms, such as Soft Actor Critic (SAC) , tend to perform poorly on learning from offline 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 ; however learning a policy using the learned value functions remains an active challenge in offline RL. Simple algorithms like fitted -iterations have been able to learn state-action value functions, but do not work well with sub-optimal data . To help solve the generalization and extrapolation problem, different offline 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 constrains include using KL-divergence , MMD or -divergence . Some algorithms have also proposed to learn a state conditioned VAEs to minimize the extrapolation error . Recent work by Buckman et al. investigated using worst-case analysis to train a policy, denoted as pessimism. Conservative -Learning (CQL) explicitly deals with the problem of overestimation for OOD state-action distribution by pushing down the value of randomly sampled state-action distributions in the critic objective . Learning a dynamics model from offline data has been promising . A recent review of offline RL outlines the state of the field . Recent work has also shown great promise using offline RL for real robotics tasks by learning policies that can directly be deployed on real robots to perform complex tasks . Similar to before, such work relies on collecting large scale robotic datasets , and learning policies that can then be safely deployed after a few steps of finetuning.
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 or self-supervision . Self-supervised representation learning has recently been applied to learn RL agents from pixel-data. By using data augmentations and contrastive learning, Laskin et al. showed significant improvements on learning from pixel data. The need for contrastive learning was simplified by RL with Augmented Data (RAD) and Data-Regularized -learning (DrQ) 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 . The closest work to S4RL include DrQ and RAD in that we utilize their method for -learning over augmentations, but in contrast we focus specifically on offline RL for robotic tasks and propose augmentations from states; we also benchmark different self-supervision techniques from states.
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 (, , , , , ), where is the state space, is the action space, is the transition function given the current state and action pair, is the reward model given the state, is the discount factor where and is the initial state distribution of the MDP.
Furthermore, a state-action value function, , is the value of performing a given action given the state . The -function is trained by minimizing the Bellman Error over in a step called policy evaluation
where is the -th step of policy evaluation. The policy is then trained to maximize the state-action values of performing an action given in a step called policy improvement:
where is the -th step of policy improvement.
Unlike traditional reinforcement learning, in offline 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 which is then used to train a target policy . The policy improvement can now be stated as
where 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 offline RL algorithms tend to generalize poorly to OOD data, the nature of and the optimality of is important. As shown Fu et al. , typical offline RL methods perform poorly when a mixture of suboptimal policies or an untrained random policy is used to collect the dataset . 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 first consider a simple -learning technique based on DrQ , which helps combine data augmentations and learning better value functions during training by encouraging local points around the state to have similar -values. Then, we introduce 7 different data augmentations strategies that can be leveraged to allow the offline agent to perform local exploration on the otherwise static dataset to reduce overfitting and improve function approximation by smoothening the state-space.
The main difference between our proposed objective and the normal -learning objective is the mean over 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 different augmentations of the same state. Intuitively, this will help improve the consistency of the -value within some perturbation field of the current state , since the Bellman backups are taken over -different views of the same state .
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 -networks to perform policy improvement using the objective in Equation 3, without augmentations. The benefits 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 -values and target values over different augmentations of the original state. Without loss of generality, to show local perturbations, we draw an -ball over the current state , however different versions of augmentations are possible, as will be discussed.
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 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.
state-switch where we flip 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 E).
Experiments
In this section, we will first describe the dataset (D4RL ), 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) , and SAC+AutoEncoder (SAC+AE) where we feed the augmentations to the AutoEncoder to learn generalizable representations . We add S4RL framework to two state-of-the-art offline RL algorithms: Conservative -learning (CQL) and Behaviour Regularized Actor Critic (BRAC) 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 first test each baseline on the full suite of D4RL tasks , 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 fine-grained control of a robotic hand , Kitchen environment which simulates a Franka Panda robot to perform kitchen tasks. We additionally experiment with more difficult robotic environments: MetaWorld which uses a simulated Sawyer robot and RoboSuite 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 significantly less data to train from. Finally, we experiment with different ways to regularize -network to prevent overfitting, such as Dropout and Weight Decay in Appendix 4 and include ablation experiments investigating the number of augmentations and the role of hyperparameters in Appendix D.
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 use 2 augmentations for obtaining the state-action values and the target values. We use a and value of for the zero-mean Gaussian and Uniform noise augmentation variant, respectively. We use a value of for for adversarial training; an ablation on and is available in Appendix D.
1 Results
We first 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 (), zero-mean Uniform noise (), 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- 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 significantly outperform the baseline CQL agent on complex data distributions such as “-medium-replay” where the data collected is from all the data 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 and CutMix . 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.
Comparison to other self-supervision techniques
Following insights from Table 1, we choose three data augmentation approaches, namely S4RL-, 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 and BRAC agents . Despite its simplicity, we continuously observe that +S4RL- and +S4RL-adv agents are able to significantly outperform the baselines on almost all tasks, and is comparable to the best in the others for both offline RL algorithms. We specifically note that +S4RL-Adv significantly 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 offline reinforcement learning.
Dexterous Manipulation Environments
Finally, we perform more experiments in the robotic domain using the MetaWorld and RoboSuite environments on difficult manipulation tasks. For MetaWorld, we train a SAC agent 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 F. The results are presented in Figure 4. Similar to before we see significant 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 significantly 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 B
Conclusion
In this paper, we present S4RL: a Surprisingly Simple Self-Supervised offline RL method that uses data augmentations to improve the function approximation for -learning algorithms in offline RL. S4RL offers simplicity and ease of implementation, and can be added to any offline agent that requries -learning. We first compare and benchmark the effectiveness of 7 different data augmentation strategies from states in offline 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 significant performance gains over the benchmark D4RL dataset and on more dexterous robot manipulation environments. We observe significant performance gains which make offline 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.
References
Appendix A Learning with limited data
Its possible that only a small amount of offline data is available to train an offline agent, which motivates us to test the agents on learning from limited data. We do this by randomly selecting 5%, 10%, and 25% of the datasets in each data split for the 3 OpenAI Gym tasks on 3 different data splits: “-medium”, “-medium-replay” and “-medium-expert”. By doing so, we significantly limit the amount of information the agent has about the environment thereby increasing the difficulty of learning a good representation from data. We present the normalized reward (y-axis) over the different data % available (x-axis) in Figure 5. On the Hopper and Walker2d data splits, the S4RL- agent is able to learn significantly outperform all the baselines on both environments in each data split and data-percent. Despite the simplicity and ease of implementation, the agent is able to learn better representations than CQL+CURL and CQL+VAE.
Appendix B Full Robotic Experiments
Appendix C Q𝑄Q-network regularization
Along with self-supervision, in deep learning literature there exist other forms of explicit regularization methods that are used to help with performing better function approximation by preventing overfitting. We include experiments with two such methods: Monte Carlo dropout mask (MC-Dropout) and L2-regularization over -network weights. The results are shown in Table 4.
Appendix D Ablation over Hyperparamaters
The results for ablation over values of and for the two best performing methods (S4RL- and S4RL-Adv) are presented in Table 5. We see that large values of or ()significantly hurt the performance of S4RL, whereas the model is relatively stable within the range of and suggesting the need for local perturbations to the proprioceptive information. A large variance or a large adversarial sample hurts the performance since the new states may be semantically different than the original state, since proprioceptive inputs are continuous unlike pixel-based input.
Appendix E Implementation details on state-switch
The implementation of the state-switch experiments is done by using ad-hoc rules for each environment where we only replace dimensions which are similar to each other. Such as a joint-angle is only replaced by another angle, and a joint velocity is only replaced by another velocity. Using this scheme ensures that we remain approximately in the same bounds of what is physically realizable, since its possible that velocities and angles do not work on the same scale. Since state-switch needs significantly more oracle knowledge of the environment and the state space, it may not be the best choice of augmentation for environments where the state space is not known. Furthermore, we see that in practice, state-switch is unable to perform well on most baselines as shown in Table 1, which consolidates the relative ineffectiveness of the augmentation choice.
Appendix F Details about Robosuite experiments
Robosuite datasets were collected by first training a Soft Actor Critic RL agent from scratch on the Lift and Can tasks. Agent checkpoints were saved regularly during training – 5 checkpoints for the Lift task, and 17 checkpoints for the Can task. For each checkpoint, 300 agent rollouts were collected (with horizon 150) for a total of 1500 Lift trajectories and 5100 Can trajectories. Consequently, these datasets contain a mixture of expert and suboptimal trajectories, and resemble datasets from common offline RL benchmarks .