Implicit Behavioral Cloning
Pete Florence, Corey Lynch, Andy Zeng, Oscar Ramirez, Ayzaan Wahid, Laura Downs, Adrian Wong, Johnny Lee, Igor Mordatch, Jonathan Tompson
Introduction
Behavioral cloning (BC) remains one of the simplest machine learning methods to acquire robotic skills in the real world. BC casts the imitation of expert demonstrations as a supervised learning problem, and despite valid concerns (both empirical and theoretical) about its shortcomings (e.g., compounding errors ), in practice it enables some of the most compelling results of real robots generalizing complex behaviors to new unstructured scenarios . Although considerable research has been devoted to developing new imitation learning methods to address BC’s known limitations, here we investigate a fundamental design decision that has largely been overlooked: the form of the policy itself. Like many other supervised learning methods, BC policies are often represented by explicit continuous feed-forward models (e.g., deep networks) of the form that map directly from input observations to output actions . But what if is the wrong choice?
In this work, we propose to reformulate BC using implicit models – specifically, the composition of with a continuous energy function (see Sec. 2 for definition) to represent the policy :
This formulates imitation as a conditional energy-based modeling (EBM) problem (Fig. 1), and at inference time (given ) performs implicit regression by optimizing for the optimal action via sampling or gradient descent . While implicit models have been used as partial components (e.g., value functions) for various reinforcement learning (RL) methods , our work presents a distinct yet simple method: do BC with implicit models. Further, this enables a unique case study that investigates the choice between implicit vs. explicit policies that may inform other policy learning settings beyond BC.
Our experiments show that this simple change can lead to remarkable improvements in performance across a wide range of contact-rich tasks: from bi-manually scooping piles of small objects into bowls with spatulas, to precisely pushing blocks into fixtures with tight 1mm tolerances, to sorting mixed collections of blocks by their colors. Results show that implicit models for BC exhibit the capacity to learn long-horizon, closed-loop visuomotor tasks better than their explicit counterparts – and surprisingly, give rise to a new class of BC baselines that are competitive with state-of-the-art offline RL algorithms on standard simulated benchmarks . To shed light on these results, we provide observations on the intuitive properties of implicit models, and present theoretical justification that we believe are highly relevant to part of their success: their ability to represent not only multi-modal distributions, but also discontinuous functions.
Paper Organization. After a brief background (Sec. 2), to build intuition on the nature of implicit models, we present their empirical properties (Sec. 3). We then present our main results with policy learning (Sec. 4), both in simulated tasks and in the real world. Inspired by these results, we provide theoretical insight (Sec. 5), followed by related work (Sec. 6) and conclusions (Sec. 7).
Background: Implicit Model Training and Inference
With a trained energy model , implicit inference can be performed with stochastic optimization to solve . To demonstrate a breadth of approaches, we present results with three different EBM training and inference methods discussed below, however a comprehensive comparison of all EBM variants is outside the scope of this paper; see for a comprehensive reference. We use either a) a derivative-free (sampling-based) optimization procedure, b) an auto-regressive variant of the derivative-free optimizer which performs coordinate descent, or c) gradient-based Langevin sampling with gradient penalty loss during training – see the Appendix for descriptions and comparisons of these choices.
Intriguing Properties of Implicit vs. Explicit Models
Discontinuities. Implicit models are able to approximate discontinuities sharply without introducing intermediate artifacts (Fig. 2a), whereas explicit models (Fig. 2d), because they fit a continuous function to the data, take every intermediate value between training samples. As the frequency of discontinuities increases, the implicit model predictions remain sharp at discontinuities, while also respecting local continuities, and with piece-wise linear extrapolations up to some decision boundary between training examples (Fig. 2a-c). The explicit model interpolates across each discontinuity (Fig. 2d-f). Once the training data is uncorrelated (i.e. random noise) and without regularization (Fig. 2c, Fig. 2f), implicit models exhibit a nearest-neighbors-like behavior, though with non-zero segments around each sample.
Extrapolation. For extrapolation outside the convex hull of the training data (Fig. 2a-f), even with discontinuous or multi-valued functions, implicit models often perform piecewise linear extrapolation of the piecewise linear portion of the model nearest to the edge of the training data domain. Recent work has shown that explicit models tend to perform linear extrapolation, but the analysis assumes the ground truth function is continuous.
Multi-valued functions. Instead of using to identify a single optimal value, may return a set of values, which may either be interpreted probabilistically as sampling likely values from the distribution, or in optimization as the set of minimizers ( is set-valued). Fig. 3 compares a ReLU-MLP trained as a Mixture Density Network (MDN) vs an EBM across three example multi-valued functions.
Visual Generalization Of particular relevance to learning visuomotor policies, we also find striking differences in extrapolation ability with converting high-dimensional image inputs into continuous outputs. Fig. 4 shows how on a simple visual coordinate regression task, which is a notoriously hard problem for convolutional networks , an MSE-trained Conv-MLP model with CoordConv struggles to extrapolate outside the convex hull of the training data. This is consistent with findings in . A Conv-MLP trained via late fusion (Fig. 4b) as an EBM, on the other hand, extrapolates well with only a few training data samples, achieving 1 to 2 orders of magnitude lower test-set error in the low-data regime (Fig. 4d). This is additional evidence that distinguishes implicit models from explicit models in a distinct way from multi-modality, which is absent in this experiment.
Policy Learning Results
We evaluate implicit models for learning BC policies across a variety of robotic task domains (Fig. 5). The goals of our experiments are three-fold: (i) to compare the performance of otherwise-identical policies when represented as either implicit or explicit models, (ii) to test how well our models (both implicit and explicit) compare with author-reported baselines on a standard set of tasks, and (iii) to demonstrate that implicit models can be used to learn effective policies from human demonstrations with visual observations on a real robot. The following results and discussions are organized by task domain – each evaluating a unique set of desired properties for policy learning (Table 1). All tasks are characterized by discontinuities and require generalization (e.g., extrapolation) to some degree.
D4RL is a recent benchmark for offline reinforcement learning. We evaluate our implicit (EBM) and explicit (MSE) policies across the subset of tasks for which offline datasets of human demonstrations are provided, which is arguably is the hardest set of tasks. Surprisingly, we find that our implementations of both implicit and explicit policies significantly outperform the BC baselines reported on the benchmark, and provide competitive results with state-of-the-art offline reinforcement learning results reported thus far, including CQL and S4RL . By adding perhaps the simplest way to use reward information, if we prioritize sampling to be only the top 50% of demonstrations sorted by their returns (similar to Reward-Weighted Regression (RWR) ), this intriguingly generally improves implicit policies, in some cases to new state-of-the-art performance, while less so for explicit models. This suggests that implicit BC policies value data quality higher than explicit BC policies do. A simple Nearest-Neighbor baseline (see Appendix) performs better than one might expect on these tasks, but on average not as well as implicit BC.
While many of the D4RL tasks have complex high-dimensional action spaces (up to 30-D), they do not emphasize the full spectrum of task attributes (Table 1) we are interested in. The following tasks isolate other attributes or introduce new ones, such as highly stochastic dynamics (i.e., single-point-of-contact block pushing), complex multi-object interactions (many small particles), and combinatorial complexity.
N-D Particle Integrator is a simple environment with linear dynamics but where a discontinuous oracle policy is used to generate training demonstrations: once within the vicinity of goal-conditioned location (Fig. 5, shown for ), the policy must switch to the second goal. The benefit of studying this environment is two-fold: (i) it has none of the complicating attributes in Table 1 and so allows us to study discontinuities in isolation, and (ii) we can define this simple environment to be in dimensions. Varying from 1 to 32 dimensions, but holding the number of demonstrations constant, we find we are able to train 95% successful implicit policies up to 16 dimensions, whereas explicit (MSE) policies can only do 8 dimensions with the same success rate. The Nearest-Neighbor baseline, meanwhile, cannot generalize, and only performs well on the 1D task (see Appendix for more analysis).
Simulated Pushing consists of a simulated 6DoF robot xArm6 in PyBullet equipped with a small cylindrical end effector. The task is to push a block into the target goal zone, marked by a green square labeled on the tabletop. We investigate 2 variants: (a) pushing a single block to a single target zone, or (b) also pushing the block to a second goal zone (multistage). We evaluate implicit (EBM) and explicit (MSE and MDN ) policies on both variants, trained from a dataset of 2,000 demonstrations using a scripted policy that readjusts its pushing direction if the block slips from the end effector. Results in Table 3 show that all learning methods perform well on the single-target task, while MSE struggles with the slightly longer task horizon. For the image-based task, the MDN significantly struggles compared to MSE and EBM. The failures of the Nearest-Neighbor baseline, with only 0-4% success rate, show that generalization is required for this task.
Planar Sweeping is a 2D environment that consists of an agent (in the form of a blue stick) where the task is to push a pile of 50 - 100 randomly positioned particles into a green goal zone. The agent has 3 degrees of freedom (2 for position, 1 for orientation). We train implicit (EBM) and explicit (MSE) policies from 50 teleoperated human demonstrations, and test on episodes with unseen particle configurations. For the image-based inputs, we also test two types of encoders with different forms of dimensionality reduction: spatial soft(arg)max and average pooling over dense features (see Appendix for architecture descriptions). For the state-based inputs, since the number of particles vary between episodes, we flatten the poses of the particles and 0-pad the vector to match the size of the vector at maximum particle cardinality.
The results in Table 4 (averaged over 3 training runs with different seeds) suggest that image-based EBMs outperform the best MSE architectures by 7%. Interestingly, image-based EBMs seem to synergize well with spatial soft(arg)max for dimensionality reduction, as opposed to pooling, which works best for MSE explicit policies. In both cases, state observations as inputs do not perform well compared with image pixel inputs. This is likely because the particles have symmetries in image space, but not when observed as a vector of poses.
Simulated Bi-Manual Sweeping consists of two robot KUKA IIWA arms equipped with spatula-like end effectors. The task is to scoop up randomly configured particles from a workspace and transport them into two bowls, which should be filled up equally. Successfully scooping particles and transporting them requires precise coordination between the two arms (e.g., such that the particles do not drop while being transported to the bowls). The action space is 12DoF (6DoF Cartesian per arm), and each episode consists of 700 steps recorded at 10Hz. Perspective RGB images from a simulated camera are used as visual input, along with current end effector poses as state input. The task is characterized by many mode changes and discontinuities (transitioning from scooping to lifting, from lifting to transporting, and deciding which bowl to transport to). EBM and MSE policies on the task use the best corresponding image encoder from the planar sweeping task. As shown in Table 5, our results show that EBM outperforms MSE by 14%.
Real Robot Manipulation, using a cylindrical end-effector on an xArm6 robot (Fig. 9a), we evaluate implicit BC and explicit BC policies on 4 real-world manipulation pushing tasks: 1) pushing a red block and a green block into assigned target fixtures, 2) pushing the red and green blocks into either target fixture, in either order, 3) precise pushing and insertion of a blue block into a tight (1mm tolerance) target fixture, and 4) sortation of 4 blue blocks and 4 yellow into different targets. The observation input is only raw perspective RGB images at 5Hz, with task horizons up to 60 seconds, and teleoperated demonstrations.
Across all four tasks, we observe significantly higher performance for the implicit policies compared to the explicit baseline. This is especially apparent on the pushing-and-oriented-insertion task (Insert Blue), which requires highly discontinuous behavior in order to subtly nudge enough, but not too far, the block into place (Fig. 9c). On this task we see the implicit BC policy has an order of magnitude higher success rate than the explicit BC policy. The sorting task in particular (Sort-Blue-From-Yellow, Fig. 9d) is our attempt to push the generalization abilities of our models, and we see a 2.4x higher success rate for the implicit policy. Note these experimental results are averaged over 3 different models, for each task, for each policy type. The red/green pushing tasks, including multi-modal variant (Fig. 9b), also show notably higher success rates for the implicit policies. These real-world results are best appreciated in our video.
Theoretical Insight: Universal Approximation with Implicit Models
In previous sections, we have empirically demonstrated the ability of implicit models to handle discontinuities (Section 3), and we hypothesized this is one of the reasons for the strong performance of implicit BC policies (Section 4). Two theoretical questions we now ask are: (i) is there a provable notion for what class of functions can be represented by implicit models given some analytical , and (ii) given that energy functions learned from data may always be expected to have non-zero error of approximating any function, are there inference risks with large behaviour shifts resulting from a combination of and spurious peaks in ? Recent work has shown that a large class of functions (namely, functions defined by finitely many polynomial inequalities) can be approximated implicitly by using SOS polynomials to represent . Here we show that for implicit models with represented by any continuous function approximator (such as a deep ReLU-MLP network), can represent a larger set of functions including multi-valued functions and discontinuous functions (Thm. 1), to arbitrary accuracy (Thm. 2). These results are stated formally in the following; proofs are in the Appendix.
Of practical note, explicit functions ( in Thms. 1 and 2) with arbitrarily small or large Lipschitz constants can be approximated by an implicit function with bounded Lipschitz constant (see Appendix for more discussion). This means that implicit functions can approximate steep or discontinuous explicit functions without large gradients in the function approximator that may cause generalization issues. This is not the case for explicit continuous function approximators, which must match the large gradient of the approximated function. In both their multi-valued nature and discontinuity-handling, the approximation capabilities of implicit models are distinctly superior to explicit models. See Fig. 10 for visual intuition, and more discussion in the Appendix.
Related Work
Energy-Based Models, Implicit Learning. Reviews of energy-based models can be found in LeCun et al. and Song & Kingma . Du & Mordatch proposed Langevin MCMC sampling for training and implicit inference, and argued for several strengths of implicit generation, including compositionality and empirical results such as out-of-distribution generalization and long-horizon sequential prediction. A general framework for energy-based learning of behaviors is also presented in . In applications, energy based models have recently shown state-of-the-art results across a number of domains, including various computer vision tasks , as well as generative modeling tasks such as image and text generation . Many other works have investigated using the notion of implicit functions in learning, including works that investigate implicit layers . There is also a surge of interest in geometry representation learning in implicit representations . In robotics, implicit models have been developed for modeling discontinuous contact dynamics .
Energy-Based Models in Policy Learning. In reinforcement learning, uses an EBM formulation as the policy representation. Other recent work uses EBMs in a model-based planning framework, or uses EBMs in imitation learning but with an on-policy algorithm. A trend as well in recent RL works has been to utilize an EBM as part of an overall algorithm, i.e. .)
Policy Learning via Imitation Learning. In addition to behavioral cloning (BC) , the machine learning and robotics communities have explored many additional approaches in imitation learning , often in ways that need additional information. One route is by collecting on-policy data of the learned policy, and potentially either labeling with rewards to perform on-policy reinforcement learning (RL) or labeling actions by an expert . Distribution-matching algorithms like GAIL require no labeling, but may require millions of on-policy environment interactions. While algorithms like ValueDice implement distribution matching in a sample-efficient off-policy setting, they have not been proven on image-observations or high degree-of-freedom action spaces. Another route to using more information beyond BC is for the off-policy data to be labeled with rewards, which is the focus of the offline RL community . All of these directions are good ideas. A perhaps not fully appreciated finding, however, is that in some cases even the simplest forms of BC can yield surprisingly good results. On offline RL benchmarks, prior works’ implementations of BC already show reasonably competitive results with offline RL algorithms . In real-world robotics research, BC has been widely used in policy learning . Perhaps the success of BC comes from its simplicity: it has the lowest data collection requirements (no reward labels or on-policy data required), can be data-efficient , and it is arguably the simplest to implement and easiest to tune (with fewer hyperparameters than RL-based methods).
Approximation of Discontinuous Functions. The foundational results of Cybenko and others in Universal Approximation of neural networks have had foundational impact in guiding machine learning research and applications. Various approaches have been developed in the function approximation literature and elsewhere to approximate discontinuous functions , which typically do not use neural networks. Also motivated by applications to modeling phenomena for robots, develops theory of approximating discontinuous functions with neural networks, but the method requires a-priori knowledge of the discontinuity’s location. Our work builds on the well-known and well-applied results in continuous neural networks, but through composition with provides a notion of universal approximation even for discontinuous, set-valued functions.
Conclusion
In this paper we showed that reformulating supervised imitation learning as a conditional energy-based modeling problem, with inference-time implicit regression, often greatly outperforms traditional explicit policy baselines. This includes on tasks with high-dimensional action spaces (up to 30-dimensional in the D4RL human-expert tasks), visual observations, and in the real world. In terms of limitations, a primary comparison with explicit models is that they typically require more compute, both in training and inference (see Appendix for comparisons). However, we have both shown that we can run implicit policies for real-time vision-based control in the real world, and training time is modest compared to offline RL algorithms. To further motivate the use of implicit models, we presented an intuitive analysis of energy-based model characteristics, highlighting a number of potential benefits that, to the best of our knowledge, are not discussed in the literature, including their ability to accurately model discontinuities. Lastly, to ground our results theoretically we developed a notion of universal approximation for implicit models which is distinct from that of explicit models.
The authors would like to thank Vikas Sindwhani for project direction advice; Steve Xu, Robert Baruch, Arnab Bose for robot software infrastructure; Jake Varley, Alexa Greenberg for ML infrastructure; and Kamyar Ghasemipour, Jon Barron, Eric Jang, Stephen Tu, Sumeet Singh, Jean-Jacques Slotine, Anirudha Majumdar, Vincent Vanhoucke for helpful feedback and discussions.
References
Appendix A Contributions Statement
Due to space constraints we did not include a comprehensive contributions statement in the main manuscript, but include one here for clarity:
We present Implicit Behavioral Cloning (Implicit BC), which is a novel, simple method for imitation learning in which behavioral cloning is cast as a conditional energy-based modeling (EBM) problem, and inference is performed via sampling-based or gradient-based optimization.
We validate Implicit BC in real-world robot experiments, in which we demonstrate physical robots performing several end-to-end, contact-rich pushing tasks (including precision insertion, and multi-item sorting) driven with only images as input, and only human demonstrations provided as training data. Implicit BC performs significantly better than our explicit BC baseline across all real-world tasks, including an order-of-magnitude increase in performance on the precision insertion task. On the sorting task, the models are shown to be capable of solving an up-to-60-second horizon for a contact-rich, combinatorial task with complex multi-object collisions.
We present extensive simulation experiments comparing Implicit BC to both comparable explicit models from the same codebase, and also author-reported quantitative results on the human-expert tasks from the standard D4RL benchmark. We find both our explicit BC and implicit BC models provide competitive or state-of-the-art performance on D4RL tasks with human-provided demonstrations, despite using no reward information. Averaged across all tasks, we find implicit BC outperforms our own best explicit BC models.
We analyze the nature of implicit models in simple 1D-1D examples, and we highlight aspects of implicit models that we believe are not known to the generative modeling community, including their behavior (i) at discontinuities and (ii) in extrapolation.
We provide theoretical insight into implicit models, including proofs of their (i) representational abilities (Thm. 1), and (ii) approximation abilities (Thm. 2), which are shown to be distinct from continuous explicit models in their ability to handle discontinuities and set-valued functions.
Appendix B Energy-Based Model Training and Implicit Inference Details
Our results critically depend on energy-based model (EBM) training, but we do not consider the specific methods we use to be our main contributions (see Sec. A for a list). That said, after considerable experience training conditional EBMs on both simple function-fitting tasks, and on policy learning tasks, we believe it is useful to the research community to describe method specifics in detail. Our goal is to emphasize simplicity when possible, in order to encourage more folks to use implicit energy-based regression rather than explicit regression. We first review our approach using derivative-free optimization, then our autoregressive version, and then our approach using Langevin gradient-based sampling. For each, we discuss (i) how to train the models, and (ii) how to perform inference with the models. For a more comprehensive overview of training EBMs, see . Note we will release code as well for training and inference.
For all methods, to compute and we (1) take the per-dimension min and max over the training data, (2) add a small buffer, typically 0.05() on each side, and then (3) clip these min and max values to the environments’ allowed min/max values. For agents that do not use the full range of the environments’ allowed values for a given dimension, this enables more precision on that action dimension. Also all methods use Adam optimizer with default , values.
Given a trained energy model , we use the following derivative-free optimization algorithm to perform inference:
While the above method works great for up to of 5 dimensions or less (Sec. B.4), we look at both autoregressive and gradient-based methods for scaling to higher dimensions.
B.2 Method with Autoregressive Derivative-Free Optimization.
B.3 Method with Gradient-based, Langevin MCMC
For gradient-based MCMC (Markov Chain Monte Carlo) training we use the approach described in which uses stochastic gradient Langevin dynamics (SGLD) :
For additional stability of training, we use both spectral normalization as in , and also add gradient penalties. Gradient penalties are well known in the GAN community, and the form of our gradient penalty is inspired by :
Where the sums over , , , represent respectively the sum over training samples, counter-examples per each data sample, and some subset of iterative chain samples for which we find it is sufficient to use only the final step, . controls the scale of the gradient relative to the noise in SGLD. If is too large, then the noise in SGLD has little effect; if is too small, then the noise overpowers the gradient. Empirically we find is a good setting. On each step of training, the gradient penalty loss is simply added to the InfoNCE loss, i.e. . Lastly, we note there are other approaches for improving stability of Langevin-based training, such as loss functions with entropy regularization .
To aid intuition on why constraints on the gradients are allowable restrictions for the model, Corollary 1.1 shows that the energy model is capable of having an arbitrary Lipschitz constant.
B.4 Comparison of EBM Variants
A key comparison between these methods is the tradeoff of simplicity for higher-dimensional action spaces. As shown in Fig. 11, with only 2,000 demonstrations in the -D particle environment, the joint-dimensions-optimized derivative-free version (Sec. B.1) fails to solve the environment past 5 dimensions, due to the curse of dimensionality and its naive sampling. Both the autoregressive (Sec. B.2) and Langevin (Sec. B.3) versions are able to solve the environment reliably up to 16 dimensions, and with nonzero success at 32 dimensions. The autoregressive version requires no new gradient stabilization, and can use only the same loss function, , but is memory-intensive, requiring separate models for dimensions. The Langevin version scales to high dimensions with only one model, but requires gradient stabilization. For more on autoregressive and Langevin generative EBMs, see and . Which variant is used for each of our evaluation tasks is enumerated in Section D.
Appendix C Additional Experimental Details and Analysis
In this section, with the table below, we highlight key aspects of the different evaluated policy learning experimental tasks, specifically the # of demonstrations for each task and the dimensionalities of the environments (comprised of the observation spaces, state spaces, and action spaces). As is highlighted in the table, the various tasks cover a wide set of challenges, including: low-data-regime tasks, and tasks with high observation, state, and/or action dimensionalities.
C.2 Training and Inference Times, Implicit vs. Explicit Comparison
D4RL Train+Eval Times. Table 6 compares example training + evaluation times for the chosen best-performing models on the D4RL tasks. We report both the training steps/second, and then also the full time for running an experiment, which comprises training to 100k steps with intermittently evaluating 100 episodes every 10k steps.
As is shown in Table 6, the best-performing implicit models, which are 100-iteration Langevin models, take 5.6x the train+eval time compared to the best-performing explicit models. Note that even the 3.4-hour full train+eval time for the implicit model is considerably faster than what has been reported for completing a train+eval on a comparable D4RL task for CQL: 16.3 hours.
Real-World Image-based Train and Inference Times. The following compares relevant training and inference times for our real-world tasks. In contrast to the D4RL scenario discussed above, in this scenario (a) there are large image observations to process, and (b) there are no simulated evaluations run during training. We report the training steps/sec rate, as well as the total train time, which is performed on a server of 8 GPUs. Once trained, the model is then deployed on a single-GPU machine, for which we report the inference times.
Table 7 shows that for these visual models, the training times are reasonably comparable for the implicit and explicit models – 5.0 and 5.8 hours respectively. Compared to the previous D4RL scenario, this can be explained because the training time is mostly dominated by visual processing. As the implicit models use late fusion (Sec. E), the visual processing time is identical to the explicit models. For inference, the chosen implicit models show a modest increase in inference time, up to 7.22 milliseconds (ms) from 3.49 ms for the explicit model. This can be attributed to time spent on the iterative derivative-free optimization. Note that the inference time of the implicit model can be adjusted by adding/decreasing the number of samples and iterations. For example, using the same trained model but increasing the samples from 1024 to 2048 causes the inference time to increase to 9.25 ms.
C.3 Additional Real-World Experimental Details
Our real-world experiments make use of a UFACTORY xArm6 robot arm with all state logged at 100 Hz. Observations are recorded from an Intel RealSense D415 camera, using RGB-only images at 640x360 resolution, logged at 30 Hz. The cylindrical end-effector is made from a 6 inch long plastic PVC pipe sourced from McMaster-Carr (9173K515). The work surface is 24 x 18 inch smooth wood cutting board. The manipulated objects are from the Play22 Baby Blocks Shape Sorter toy kit (Play22). The targets for the tasks were constructed by hand out of wood and spraypainted black. All demonstrations were provided by a mouse-based interface for providing real-time demonstrations.
The 6DOF robot is constrained to move in a 2D plane above the table. This aids in safety of the robot during operation, since it is constrained to not collide with the table and cannot provide normal forces against objects down into the table either.
C.3.2 Robot Policy and Controller
The learned visual-feedback policy operates at 5 Hz. On a GTX 2080 Ti GPU, the implicit models (configuration in Sec. D.5) complete inference in under 10 ms (see Sec. C.2), and so could be run faster than 5 Hz, but we find 5 Hz to be sufficient. The learned action space is a delta Cartesian setpoint, from the previous setpoint to the new one. The setpoints are linearly interpolated from their 5 Hz rate to be 100 Hz setpoints to our joint level controller. The joint level controller uses PyBullet for inverse kinematics, and sends joint positions to the xArm6 robot at 100 Hz.
C.4 Nearest-Neighbor Baseline
This baseline memorizes all training data, and performs inference by looking up the closest observation in the training set and returning the corresponding action. Specifically, given a finite training dataset of pairs , denote the inputs as and outputs , preserving the ordering in both and . Given some new observation , the Nearest-Neighbor model, , computes:
for some norm . Specifically we used L2 norm. We experimented with normalizing all observations per-dimension to be unit-variance, but did not find this to improve results. For environments with state-only observations (no images), we can compute this exactly and quickly all in processor memory, but for the image-observation Simulated Pushing task we tested, the dataset did not fit in memory. Accordingly, we used a random linear projection, which is known to be a viable method for nearest-neighbor lookup of image data , from the observation space to a 128-dimensional vector. We then stored all these 128-dimensional vectors in memory, and used these for Nearest-Neighbor lookups.
C.5 N𝑁N-D Particle Environment Description
C.6 Analysis: Training Data Sparsity in the N𝑁N-D Particle Tasks
To complement other analyses on generalization, sample complexity, and interpolation/extrapolation, we analyze in Fig. 12 another notion of generalization: training data sparsity. In the -D particle experiments, as we increase N but hold the number of demonstrations constant, the training data effectively becomes much sparser over the observation space. New test-time environments for evaluation are accordingly, as increases, on average farther and farther away from the training set. This helps explain how the Nearest-Neighbor baseline cannot solve this task well past 1D, since memorizing the training data is insufficient, and to succeed in a higher-dimensional environment a model must generalize. This analysis complements our simple 1D->1D figures on extrapolation/interpolation (Fig. 2 and Fig. 3 in the main paper) and our visual generalization and sample complexity analysis (Fig. 4 in the main paper).
C.7 Additional D4RL tasks
In the main paper we focused on the human-expert tasks from D4RL, but here provide results on additional D4RL tasks as well. Note that the other tasks shown, except for ‘random’, use a reinforcement-learning-trained agent for the task, and this reinforcement-learning agent itself has a policy that is a uni-modal continuous, explicit function approximator, and it was optimized as such. Additionally, as expected, supervised imitation learning methods, which do not make use of the additional reward information from the provided demonstrations, perform comparatively worse on tasks with sub-optimal demonstrations. This is true of all tasks with “*medium*” and “*random” in their task name. Additionally, as stated in Section D, we choose the EBM hyperparameters to maximize performance on the human-expert based environments (“Franka” and “Adroit” tasks) at the expense of lower performance on the “Gym”-mujoco tasks. However, for fair comparison with other methods, and according to the standard D4RL evaluation protocol, a single set of hyperparameters was used for all tasks rather than presenting results that maximize each environment.
Appendix D Policy Learning Results Overview and Protocol
In each section below we describe the protocols for the individual simulation experiments. Note that Figure 5 was produced by averaging the performance of the best policies, for each type, within each domain across the different tasks of that domain.
For EBM variants that were used for which task: Simulated Pushing and Real World, with action dimensionality of 2, used derivative-free optimization (Sec. B.1). For Planar Sweeping, with action dimensionality 3, and Bi-Manual Sweeping, with action dimensionality 12, we used autoregressive derivative-free optimization (Sec. B.2). D4RL, with action dimensionality between 3 and 30, used Langevin dynamics (Sec. B.3). Particle, with action dimensionality between 1 and 32, used Langevin dynamics as well. See Sec. B.4 for a comparison of variants.
For D4RL experiments, we run sweeps over several hyperparameters for both the Implicit BC (EBM) and Explicit MSE-BC models. We choose the final hyperparameters based on max average performance over 3 D4RL environments: hammer-human-v0, door-human-v0, and relocate-human-v0. We use the same final hyperparameters across all D4RL tasks for the final results. Note that we paid closest attention to the human-teleoperation task performance when selecting a single set of hyper parameters for D4RL, particularly at the expense of slightly lower task performance on the gym-mujoco D4RL tasks. For all evaluations, we report average results over 100 episodes for 3 seeds. To calculate the aggregate D4RL performance metric “D4RL Human-Experts" in Figure 5 of the paper, we first calculated the normalized performance metric for the kitchen-complete, kitchen-partial, kitchen-mixed, pen-human, hammer-human, door-human and relocate-human environments, then calculated the average across all these tasks.
The following hyperparameters were used for D4RL evaluation:
Shown also is an indication of training stability, across 5 different seeds, shown for the pen task.
D4RL Explicit MSE-BC
D.2 Simulated Pushing Experiments
For Simulated Pushing experiments, we run separate sweeps for each model for each of the States and Pixels versions of the task. All chosen hyperparameter sweeps and chosen values are given in tables below, and results are reported as the average of 100 episodes for 3 seeds.
Simulated Pushing, States, Explicit MSE-BC
Simulated Pushing, States, Explicit MDN-BC
Simulated Pushing, Pixels, Implicit BC (EBM)
Simulated Pushing Pixels MSE-BC
Simulated Pushing Pixels MDN-BC
D.3 Simulated N𝑁N-D Particle Environment Experiments
For a detailed description of this environment and its dynamics, see Section C.5. We used the following hyper parameters for evaluation on this environment:
Particle Explicit MSE-BC
D.4 Simulated Sweeping Experiments
For Planar Sweeping, for both explicit and implicit models, results are shown for different types of encoders, and different of Dense ResNet layers (Sec. E) shown in the table, each is the average of 100 evaluations each across 3 different seeds. The best models, for each implicit and explicit, were taken from Planar Sweeping and evaluated on Bi-Manual Sweeping.
We used the following hyper parameters for evaluation on the simulated planar sweeping, and bi-manual sweeping environment:
Planar Sweeping Explicit MSE-BC
Bi-manual Sweeping Implicit BC (EBM)
Bi-manual Sweeping Explicit MSE-BC
D.5 Real-world Pushing Experiments
For Real World, explicit and implicit models were taken from Simulated Pushing, Pixels, and applied to the real world. We used the following hyper parameters for evaluation on the real-world pushing environments:
Pushing Pixels MSE-BC
Appendix E Model Architectures
E.2 ConvMLPs
For visuomotor models (Fig. 14b), we use the common ConvMLP style architecture, but when used as an EBM, concatenate actions with image encodings from a CNN model. The MLP portion is identical to the section above. For the CNNs, for all models for the sweeping experiments, we used 26-layer ResNets (“ConvResNets”) which maintain full-image spatial resolution before the encoder. For the simulated and real-world pushing experiments, we used a progressively-spatially-reduced model (“ConvMaxPool”) composed of interleaving convolutions with max-pooling, with feature dimensions . Both models used 3x3 convolution kernels. Configurable options include: using CoordConv , i.e. a pixel coordinate map augmented as input, and either spatial soft (arg)max or global average pooling encoders.
Appendix F Proofs
In this section we prove Theorems 1 and 2 as stated in Section 5 of the paper.
A function is Lipschitz continuous with constant if for all . We say that is -Lipschitz, so a 1-Lipschitz function is a function that is continuous with Lipschitz constant 1. The magnitude of the gradient of an -Lipschitz function is always less than or equal to .
A closed set is a set that contains all of its boundary points (points that can be approached from the interior and exterior of the set). Equivalently, a set if closed if and only if it contains all of its limit points (points that are the limit of some sequence of points in the set).
F.2 Proofs
The distance function from a point to a non-empty set, is defined as:
For any , let be a point in the closure of with . Then, to establish continuity using the triangle inequality, we can state that for a given at a distance from (as pictured in Fig. 15(a)),
Let be a closed ball of radius around . The distance from to is equal to the distance from to . Since is defined as an infimum, there must exist an infinite sequence of points with distances whose limit is . The set is closed and bounded and, therefore, compact. The infinite sequence must therefore have at least one sub-sequence that converges to a point . Since the distances of the full series converge to , we know that . ∎
Since the graph is a non-empty set the distance function is well defined and continuous, as shown in Lemma 3.
We must still show that for all . We know that , because is a distance function.
Consider a point where and therefore . Since is continuous, is closed and there will exist a point, that achieves the infimum, .
At least one of or , so .
We can again define as the distance to . Because is a non-empty set, we know that is well-defined and uniformly continuous (Lemma 3).
We will now show that for all points in and for all points not in .
At least one of or , so .
Because the empty set is excluded from the range of , there will be at least one for any . Therefore, at , the minimum value of will be zero and exactly.
We have shown that the implicit function is well-defined and continuous and has a Lipschitz value of 1, even if is very badly behaved. ∎
Corollary 1.1 The function in Thm. 1 can be chosen to have an arbitrary positive Lipschitz constant.
Therefore, has a Lipschitz constant of . ∎
Let , twice the distance to the graph of . By Thm. 1, this is continuous and satisfies .
The question now is whether bounded errors in approximating , when composed with argmin, can provide any guarantee on a property of .
Note that as an approximator for is unbounded, since may be badly behaved. This can be demonstrated at any point where has a discontinuity. Suppose and and have values that are arbitrarily far apart. Because of the error in , the may find values in that introduce arbitrary error in .
Let . For any point in the graph of , we can show that . Let be any point in . Since is in the graph of , we know that . With the bounded error, , we know that . Thus, although the argmin may be achieved elsewhere, may not have a value greater than .
Also because is an approximator for , we know that for ( in the graph of , and thus . Since is twice the distance to the graph of , the distance from to the graph of is less than .
Therefore, any point in the graph of must lie within of , the graph of .
Note that this is not symmetric. There are no guarantees on other than that it is continuous and within of . A point in may be arbitrarily far from as tiny variations in can eliminate some values from the set . ∎
Appendix G Theory Implications and Discussion
The practical implications of Theorems 1 and 2 are that they provide a number of favorable properties for real-world modeling tasks, such as robot policy learning, that exhibit discontinuities and multi-modalities. For one, implicit functions can model steep or discontinuous oracle policies without large gradients in the function approximator. We hypothesize this leads to policies with better stability characteristics and fewer generalization issues for out-of-domain samples. Thm. 1 also shows that implicit models can represent represent multi-valued (set-valued) functions, including ones with discontinuities. With Thm. 2 there is a notion provided of still having guarantees on the output of implicit inference, despite expected errors in the function approximator. One way to consider the guarantee is via the level sets of the function, as shown in Figure 10 of the main paper. To discuss an illustrative example, for a simple step function discontinuity (as in Figure 10) this guarantee provides that, although the precise “decision boundary” of the discontinuity may not be represented perfectly, that decision boundary can be approximated to arbitrary precision. Further, even when the decision boundary is estimated imperfectly, the inferred values will correspond to either side of the discontinuity, and nowhere else (it will not, for example estimate a value somewhere halfway between the two sides of the discontinuity).
Note also that Theorems 1 and 2 do not show that a learning algorithm will actually be able to recover a model with such properties, but only that such a model exists. This is in line with other results in function approximation with neural networks, for example . Additionally, in the implicit model case another consideration is not only whether the parameters of such a parameterized model, can be found, but then also whether at inference time the optimization problem can even be solved. In general, will be non-convex, and may be a hard global optimization problem. We have shown in practice, however, we are able to perform satisfactory inference on many policy learning tasks of interest.
Appendix H Limitations
Although we have examined performance increases on several tasks using implicit BC policies over explicit BC policies, evaluated as a method for behavioral cloning, there are a few limitations. For one, compared to a simple Mean Square Error (MSE) BC policy, there is both increased training and inference computational cost. As shown in Sec. C.2, however, the increase in inference time for the models used in the real world is modest, and we have validated the models in the real world to be fast enough for real-time vision-based control. Further, the training times of our presented models are modest compared to reported numbers for offline RL methods (Sec. C.2) A second limitation is the increased implementation complexity of implicit models compared to explicit models. However, we have provided a guide (Sec. B) for how to train the models, which we hope encourages readers to try implicit models.