Bayesian Optimization in Variational Latent Spaces with Dynamic Compression

07/10/2019 ∙ by Rika Antonova, et al. ∙ Facebook KTH Royal Institute of Technology 0

Data-efficiency is crucial for autonomous robots to adapt to new tasks and environments. In this work we focus on robotics problems with a budget of only 10-20 trials. This is a very challenging setting even for data-efficient approaches like Bayesian optimization (BO), especially when optimizing higher-dimensional controllers. Simulated trajectories can be used to construct informed kernels for BO. However, previous work employed supervised ways of extracting low-dimensional features for these. We propose a model and architecture for a sequential variational autoencoder that embeds the space of simulated trajectories into a lower-dimensional space of latent paths in an unsupervised way. We further compress the search space for BO by reducing exploration in parts of the state space that are undesirable, without requiring explicit constraints on controller parameters. We validate our approach with hardware experiments on a Daisy hexapod robot and an ABB Yumi manipulator. We also present simulation experiments with further comparisons to several baselines on Daisy and two manipulators. Our experiments indicate the proposed trajectory-based kernel with dynamic compression can offer ultra data-efficient optimization.



There are no comments yet.


page 6

page 12

page 13

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Reinforcement learning (RL) is becoming popular in robotics, since in some cases it can deal with real-world challenges, such as noise in control and measurements, non-convexity and discontinuities in objectives. However, most flexible RL methods require thousands to millions of data samples, which can make direct application to real-world robotics infeasible. For example, 10,000 30s trials/episodes on a real robot would require 100 hours of operation. Most full-scale platforms, especially in locomotion, cannot operate this long without maintenance. Nowadays, commercially available arms can operate for longer, however sophisticated anthropomorphic hands and advanced grippers are still highly prone to breakage after even a handful of trials [1]. Hence the need for algorithms that can learn in very few trials, without causing significant wear-and tear to the hardware.

In this work we focus on cases with a budget of only 10-20 trials. In such settings, using approaches like Bayesian optimization (BO) to adjust parameters of structured controllers can help improve data efficiency. However, success of BO on hardware has been demonstrated either with low-dimensional controllers or with simulation-based kernels that required hand-designed features. We propose learning simulation-based kernels in unsupervised way with a sequential variational autoencoder (SVAE). Our approach embeds simulated trajectories to a space of latent paths

, and jointly learns a probability distribution

that controllers with parameters induce over the space of latent paths. Our work is inspired by initial success of trajectory-based BO kernels [2], however that was demonstrated for BO in low dimensions (2-4D). Our results show that performance of a kernel based on raw trajectories deteriorates quickly for higher-dimensional problems. In contrast, a kernel based on latent paths can still offer gains even for 48-dimensional controllers.

Global optimization in latent space can still suffer from sampling unsuccessful controllers, especially in the absence of dense rewards. One solution can be adding domain-specific constraints to point optimization in the right direction. While these can be hard to define in controller parameter space, frequently they can be easily expressed in observation/state space. For example, high velocities might be undesirable if they result in hard impacts. However, formulating this as constrained optimization could result in overly conservative controllers. Instead, we incorporate controller desirability into BO by reducing exploration in the part of the trajectory space that leads to undesirable behavior. We compress the search space during BO dynamically by scaling the distance between controllers based on their desirability, initially inferred from simulation. BO can then quickly reject the undesirable parts of the search space, allowing for more exploration in the desirable parts. Figure 1 gives an overview of the proposed approach.

We test our approach (SVAE-DC: informed kernel with Dynamic Compression) on a Daisy hexapod and an ABB Yumi manipulator on hardware111Video demonstrating hardware experiments:

. We also conduct further simulation-based analysis on Daisy and two manipulators. On Daisy, our method consistently learns to walk in less than 10 hardware trials, outperforming uninformed BO. We also demonstrate significant gains on a nonprehensile manipulation task on Yumi. All latent components of our kernel can be adjusted online (by optimizing marginal likelihood as is done for BO hyperparameters). We anticipate that such adjustment could be useful for future works for settings with a medium budget of trials (

100+). Our code builds on the recently released BoTorch library [3] that supports highly scalable BO on GPUs. We open source our code for simulation environments, training and BO222SVAE-DC and BO code:

Figure 1: An overview of our approach: We start by simulating controllers and collecting their trajectories , along with the fraction of time spent in undesirable regions given by . Next, we learn to embed trajectories into a lower-dimensional a space of latent paths . We use dynamic compression to scale distances between latent paths based on their desirability. This dynamically compressed latent space is used for BO on hardware.
Trajectory data

consists of high-frequency readings of robot joint angles and object position/velocity estimates (the framework can accommodate vision-based data in the future, but we do not experiment with it in this work).

2 Background and Related Work

For learning with a small number of trials we turn to Bayesian Optimization (BO). BO can be thought of as a data-efficient RL method that obtains a reward only at the end of each trial/episode. For higher-dimensional robotics problems BO can benefit significantly from using simulation-based kernels. However, previous work required defining domain-specific features to be extracted from large-scale simulation data (see Section 2.1). Variational Autoencoders (VAEs) [4] provide an unsupervised alternative for embedding high-dimensional observations into a lower-dimensional space. For example, [5] recently used VAE in a Gaussian Process (GP) kernel to optimize chemical molecules. In robotics, VAEs have been used to process visual and tactile data (see [6] for a survey). We are interested in encoding trajectory data, so a sequential VAE (SVAE) could be applicable. [7, 8] show SVAEs learning latent dynamics. However, their physics simulations are low-dimensional (e.g. position of a 2D ball), sequences have length 20-30 steps, and the focus is on visual reconstruction. We aim to develop SVAE architecture that can easily handle simulations from full-scale robotics systems (state spaces 27D+) and much longer sequences (lengths 500-1000).

Our original motivation for embedding trajectory data into the kernel was Behavior Based Kernel (BBK) [2]. On low-dimensional problems it matched the performance of PILCO [9]

, which is a popular data-efficient model-based RL algorithm for small domains. BBK is directly applicable only to stochastic policies, but we adapted it to our setting as BBK-KL baseline. We randomize simulator parameters when collecting trajectories. Hence even though the simulator and controllers are deterministic, each controller still induces a probability distribution over the trajectories. As proposed for BBK, for kernel distances we used symmetrized KL between trajectory distributions induced by the controllers. The generation and reconstruction parts of SVAE were used to estimate this KL. Since this baseline uses a neural network in the kernel, there is some relation to methods like 

[10, 11] (though these focused on GP regression, and did not incorporate trajectories).

2.1 BO for Locomotion and Manipulation

Locomotion controllers most commonly used for real systems are structured and parametric [12, 13, 14]. BO has been used to optimize their parameters, e.g. [15, 16, 17]. Typically, these methods take 40 trials for low-dimensional controllers (3-5D). For high-dimensional controllers further domain information is needed. For example [18] use simulation and user-defined features to transform the space of a 36-dimensional controller into 6D, making the search for walking controllers of a hexapod much more data-efficient. [19] employ bipedal locomotion features to build informed kernels.

In manipulation, active learning and BO have been used, for example, for grasping 

[20, 21]. These works did not incorporate simulation into the kernel, so their performance would be similar to BO with uninformed/standard kernel. [22] showed advantages of a simulation-based kernel, but needed grasping-specific features. Somewhat related are works in sim-to-real transfer, like [1], though many have visuomotor control as the focus (not considered here) and usually do not adapt online.  [23] do adjust simulation parameters to match reality, so it would be interesting to combine this with BO in the future for global optimality (their work employs PPO, which is locally optimal). Due to uncertainty over friction and contact forces, sim-to-real is challenging for non-prehensile problems. However, such motions can be useful to make solutions feasible (e.g pushing when the object is too large/heavy to lift or the goal is out of reach). [24, 25, 26] report success in transfer/adaptation on a push-to-goal task, showing the task is challenging but feasible. In our experiments we consider a ‘stable push’ task: push two tall objects across a table without tipping them over. The further challenges come from interaction between objects and inability to recover from them tipping over.

2.2 Challenges of Real-world Locomotion: the Need for Ultra Data-efficient Optimization

Learning for legged locomotion can be a daunting task, since a robot needs to perfectly balance its interaction forces with the ground to move forward. For a hexapod robot, this means coordinating the movements of six legs, as well as the forces being applied on each leg. While it is easy to find a walking gait, it is extremely difficult to find a gait that can move forward at a reasonable speed.

Recently, [27, 28] showed that RL can be used for locomotion on hardware. However, they learn conservative controllers in simulation and help transfer via system identification of actuator dynamics [27] and a user-designed structured controller [28]. While these methods can help, they do not guarantee that a controller learned in simulation will perform well on hardware. [29] showed learning to walk on a Minitaur quadruped in only two hours. The Minitaur robot has 8 motors that control its longitudinal motion, and no actuation for lateral movements. In comparison, our hexapod (Daisy) has 18 motors, and has omni-directional movements. This makes the problem of controlling Daisy especially challenging, and would require significantly longer training. However, most present day locomotion robots get damaged from wear and tear when operated for long. For example, in the course of our experiments, we had to replace two motors, and fix issues such as faulty wiring and broken parts multiple times. With these considerations, we develop a ultra data-efficient approach that can learn controllers on Daisy in less than 10 hardware trials.

3 SVAE-DC: Learning Informed Trajectory-based Embeddings

We model our setting as a joint Variational Inference problem: learning to compress/reconstruct trajectories while at the same time learning to associate controllers with their corresponding probability distributions over the latent paths. For this we develop a version of sequential VAE (SVAE). The training is guided by ELBO (Evidence Lower Bound) derived for our setting directly from the modeling assumptions and doesn’t require any auxiliary objectives. First, we define notation:

  • [leftmargin=*]

  • : policy/controller with parameters ; policies can be either deterministic or stochastic; for brevity we will refer to simply as ‘controller

  • : original trajectory for time steps containing high-frequency sensor readings

  • : latent space ‘path’ (embedding of a trajectory)

  • : a conditional probability distribution over the trajectories induced by controller

    ; the relationship between the controller and trajectories could be probabilistic either because the controller is stochastic, or because the simulator environment is stochastic, or both

  • : a conditional probability distribution over latent space paths induced controller by

  • a map denoting whether an observation is within an undesirable region

  • : fraction of time spends in undesirable regions; captures analogous notion in latent space

Figure 2: A sketch of generative and inference model.

Our goal is to learn . is analogous to , only the paths are encoded in a lower-dimensional latent space. This is useful for constructing kernels for efficient BO on hardware. As a measure of trajectory ‘quality’ we can keep track of how long each trajectory spends in undesirable regions (). For the latent paths we learn the analogous notion (). We will not impose hard constraints during optimization, so used to compute can be specified roughly with approximate guesses. Our framework also supports , but for users it is frequently easier to make a rough thresholded estimate rather than providing smooth estimates or probabilities. The graphical model we construct for this setting is shown in Figure 2. Not all independencies are captured by the illustration. So explicitly, the generative model is:
Approximate posterior is modeled by: .
We collect trajectories by simulating controllers with parameters for time steps. We derive ELBO for this setting to maximize . Using ‘’ over the variables to indicate samples from the current variational approximation, we get:


Some aspects of this model resemble a setup from [30]; see derivation details in Appendix A.

4 Bayesian Optimization with Dynamic Compression

In Bayesian Optimization (BO), the problem of optimizing controllers is viewed as finding controller parameters that optimize some objective function : . At each optimization trial BO optimizes an auxiliary function to select the next promising to evaluate. is commonly modeled with a Gaussian process (GP): .

The key object is the kernel function , which encodes similarity between inputs. If is large for inputs , then ) strongly influences . One of the most widely used kernel functions is the Squared Exponential (SE) kernel: , where

are signal variance and a vector of length scales respectively.

are called ‘hyperparameters’ and are optimized automatically by maximizing marginal likelihood ([31], Section V-A). SE belongs to a broader class of Matérn kernels. One common parameter choice yields Matérn: . SE and Matérn kernels are stationary, since they depend on , and not on individual . Section 2.1 discussed recent work that showed how to effectively remove non-stationarity by using informed feature transforms for kernel computations. But these required extracting domain-specific features manually, or learning to fit a pre-defined set of features using a deterministic NN in a supervised way.

We propose to use learned by SVAE-DC. [2] showed that a ‘symmetrization’ of KL divergence can be used to define a KL-based kernel for trajectories in the original space:


We could use this to define an analogous kernel in the latent space:

In theory, this would be a natural way to define a path-based kernel in the latent space. However, it is widely known that Variational Inference tends to under-estimate variances in theory [32, 33] and in practice [34, 35]. This underestimation could negatively impact the practical performance of such kernel. Since we indeed observed variance under-estimation we implemented a version of the kernel to work with the latent means directly. We define our kernel function with:


This formulation is convenient in practice, since the form of Equation 4 allows us to apply existing machinery for optimizing kernel hyperparameters . We can also define SVAE-DC-Matérn version of the kernel by changing the form of Equation 4 to the Matérn function. Scaling latent representations by yields dynamic compression: latent representations that correspond to controllers frequently visiting undesirable parts of the space are scaled down. Hence ‘bad’ controllers are brought closer together. This allows BO to reduce the number of samples from the ‘bad’ parts of the space. ‘Dynamic compression’ here means this search space transformation is applied after SVAE training, in addition to the compression obtained by SVAE’s dimensionality reduction. The scaling can be made non-linear with . This can help achieving aggressive compression in settings like ours with an extremely small budget of trials. The additional parameters , as well as can be optimized online in the same way as BO hyperparameters.

Overall, SVAE-DC and the resulting kernel described above allow us to obtain a fully automatic way of learning latent trajectory embeddings in unsupervised way. For domains where is given we can also achieve dynamic compression of the latent space, making BO ultra data-efficient. All the components used during BO can be optimized online via the same methods already implemented for automatically adjusting BO hyperparameters.

5 SVAE-DC: NN Architectures and Training

Guided by prior literature we experimented with RNNs, LSTMs, and sequence-to-sequence RNNs. Learning was slow and frequently unsuccessful, despite trying adaptive learning rates, manual tuning, weighting various parts of ELBO. Using MLPs instead did not improve performance either. [36] notes that CNNs can succeed on sequence data, but one recent alternative (Quasi-RNNs [37]) did not yield a notable improvement for us. Instead, an effective idea we had was to view dimensions of as different channels. Then we could feed to 1D convolutional layers to learn , de-convolutional for

. With that, for all our experiments (all different robot and controller architectures) we were able to use the same network parameters: 3-layer 1D convolutions with [32, 64, 128] channels (reverse order for de-convolutions; kernel size 4, stride 2) followed by MLP layer for

outputs. We were also able to use same latent space sizes: 3-dimensional , latent sequence length . This yielded a small 9D optimization space for BO, which is highly desirable for optimization with few trials. Notably, this NN architecture also retained good reconstruction accuracy, not far from results with larger latent spaces () and hidden sizes (256-1024). We also interpreted as a sequence of length 1 and used de-convolutional architecture for . It had 4-layers with [512, 256, 128, 128] channels, since was one of the key parts for BO (though a smaller CNN or MLP could have sufficed). For we used a 2-layer MLP (hidden size 64). Training took 30-180 minutes on 1 GPU, using learning rate (halving after each 5K gradient updates, stopping at ). See Appendix B for reconstruction/generation visualizations.

6 Locomotion on the Daisy Hexapod

For our locomotion experiments we used Daisy robot (Figure 3) from Hebi robotics [38]. It has six legs, each with 3 motors – base, shoulder and elbow. The robot is practically omni-directional, however, the motors are velocity limited, so the robot is unable to achieve very high velocities. Vive tracking system was used to measure robot’s position in the global frame for rewards.

In general, locomotion is a hard learning problem, but complex high degree-of-freedom robots further complicate it. While in simulation all 6 legs of Daisy are identical, each motor has a slightly different behavior on hardware. This also depends on the environment, and makes it extremely hard to predict the robot’s behavior from simulation. For example, one of our successful straight-walking controllers from simulation, turns left when executed on a carpet floor, but turns right on a wooden floor. This raises the need for learning approaches that can transfer information from simulation to hardware, without suffering too much from the mismatch between the two. We simulated the Daisy robot in PyBullet 

[39]. The simulator was fast, but did not have an accurate contact model with the ground. While free-space motion of individual joints transferred to hardware, the overall behavior of the robot when interacting with the ground was very different between simulation and hardware. As a result, rewards obtained by controllers in simulation could be significantly different on hardware.

Figure 3: Daisy hexapod used in this work.

Daisy Controllers: We used Central Pattern Generators (CPGs) from [40]. These are capable of generating a large number of locomotion gaits by changing the frequency, amplitude, and offset of each joint, as well as the relative phase differences between joints. Different CPG parameters can be restricted to obtain controllers with various dimensionalities. We experimented with 11D controller on hardware and 27D in simulation. For hardware, we assume that all joints have the same amplitude, frequency and offset (3 parameters), all base motors have independent phases (6 parameters), all shoulders and elbows have the same phase difference w.r.t. the base (2 parameters). This assumption implies that all joints are treated identically, which doesn’t always hold, since each motor has slightly different tracking and bandwidth. In the future, we would like to use alternatives that allow each motor to learn independently. For simulation: base, shoulder and elbow joints were allowed to have independent amplitudes, frequencies and offsets, but fixed across the six legs (9 parameters); each of the 18 joints was allowed to have an independent phase (18 parameters).

6.1 Daisy Experiments

For SVAE-DC training we sampled controllers randomly in simulation and collected the corresponding trajectories for time steps (). For dynamic compression the states were marked as undesirable if they had: high joint velocities (more than 10rad/sec); robot base tilting by more than 60°in roll and pitch, elbows hitting the ground; height of the base outside of [0.1, 0.7]cm from the ground. These aimed to reduce the chance of robot breaking: controllers with high joint velocities can harm the motors on impact with the ground; tilting the torso can cause the robot to fall on its back; scraping the ground or lifting off and then falling can cause further damage. Since our BO trials were in a narrow walkway, we also marked as undesirable states deviating more than m from the starting -coordinate of the base. The objective function for BO was: , where was the final -coordinate of the robot (how much the robot walked forward), was the number of timesteps with velocities exceeding 10rad/sec. All BO experiments used UCB acquisition function (with ).

Figure 4: BO on Daisy hardware. Mean over 5 runs, 90% CIs.

We completed 5 runs of BO on the Daisy robot hardware, initializing with 2 random samples, followed by 10 trials of BO (Figure 4). BO with SE kernel used the same initialization as BO with SVAE-DC kernel. For Daisy robot on hardware the controller would be considered acceptable if it walked forward for more than during a trial of 25 seconds. For comparison to random search we sampled 60 controllers at random. Of these only 2 were able to walk forward a distance of over in . So the problem was challenging, as the chance of randomly sampling a successful controller was %. BO with SVAE-DC kernel found walking controllers reliably in all 5/5 runs within fewer than 10 trials. In contrast, both BO with SE found forward walking controllers only in 2/5 runs.

For simulation experiments, we created an artificial ‘sim-to-real’ gap, allowing to gauge the potential for simulation-based kernels without running all the experiments on hardware. For each BO run we randomly sampled ground restitution parameters, and kept them fixed for all trials within a run. Hence simulation-based kernels did not have full information about the exact properties of the environment used during BO (even though the range of parameters was the same as for data collection). Kernels were informed about performance on a range of parameters, but could have caused negative transfer by lagging to identify controllers that perform best in a particular setting (not only well on average across settings).

Figure 5: BO for Daisy in simulation. Means over 50 runs, 90% CIs.

Figure 5 shows BO with 27D controller. BO with SVAE-DC outperformed all baselines. BBK-KL kernel obtained smaller improvements over SE and Random baselines. This indicated that a trajectory-based kernel was useful even when optimizing a high-dimensional controller, although BBK-KL benefits were greatly diminished compared to BBK results for 2-4 dimensional controllers reported in prior work. In these experiments, SVAE without dynamic compression was very similar to SE (omitted from the plot for clarity, since it was overlapping with SE). This showed that dimensionality reduction alone does not guarantee improvement (even when the latent space contains information needed to decode back into the space of original trajectories).

7 Manipulation Experiments

Figure 6: “Stable push” task with Yumi

Our manipulation task was to push two objects from one side of the table to another without tipping them over. For Yumi environment the objects had mass and inertial properties similar to paper towel rolls (mass of 150g, 22cm height, 5cm radius); for Franka these had properties similar to wooden rolls (2kg, 22cm height, 8cm radius). Compared to ‘push-to-target’ task, our task had two different challenges. The objects were likely to come into contact with each other (not only the robot arm). Moreover, they could easily tip over, especially if forces were applied above an object’s center of mass. Reward was given only at the end of the task: the distance each upright object moved in the desired direction minus a penalty for objects that tipped over (with being table width): .

Controllers: We tested our approach on two types of controllers: 1) joint velocity controller suitable for robots like ABB Yumi and 2) torque controller suitable for robots like Franka Emika. The first was parameterized by 6 joint velocity “waypoints”, one target velocity for each joint of the robot arm (so parameters for a 7DoF arm). Each “waypoint” also had a duration parameter that specified the fraction of time to be spent attaining the desired joint velocities. Overall this yielded a 48-dimensional parametric controller. The second controller type was aimed to be safe to use on robots with torque control that are more powerful than ABB Yumi. Instead of exploring randomly in torque space, we designed a parametric controller with desired waypoints in end-effector space. Each of the 6 waypoints had 6 parameters for the pose (3D position, 3D orientation) and 2 parameters for controller proportional and derivative gains. Overall this yielded a 48-dimensional parametric controller:

. This controller interpolated between the waypoints using a

order minimum jerk trajectory for positions, and used linear interpolation for orientations. End effector Jacobian for the corresponding robot model was used to convert to joint torques.

7.1 Experimental Setup and Results

For training SVAE-DC we collected 500,000 simulated trajectories for both Yumi and Franka robot. These contained joint angles of the robot and object poses at each time step (1000 steps for Yumi and 500 steps for Franka, simulated with pybullet at 500Hz). A step on the trajectory was marked as undesirable when: any object tipped over or was pushed beyond the table; robot collided with the table or the end effector was outside of main workspace (not over the table area). Mass, friction and restitution of the objects were randomized at the start of each episode/trajectory. Randomization ranges were set to roughly resemble variability of how real-world objects behaved.

ABB Yumi robot available to us could operate effectively only at low velocities ( of simulation maximum). High-velocity trajectories successful in simulation yielded different results on hardware. To prevent Yumi from shutting down due to high load we stopped execution if the robot’s arm extended too far outside the main workspace, also stopped if it was about to collide with the table (giving reward in such cases). These factors caused a large sim-real gap. Nonetheless,

Figure 7: BO on ABB Yumi hardware (mean of 5 runs, 90% CIs).

BO with SVAE-DC kernel was still able to significantly outperform BO with SE (Figure 7). Even when controllers successful in simulation yielded very different outcomes on hardware, SVAE-DC kernel was still able to find well-performing alternatives (more conservative, yet successful on hardware).

For simulation experiments with manipulators we emulated ‘sim-to-real’ gap as with Daisy simulation: sampled different object properties (mass, friction, restitution) at the start of each BO run. Results in Figure 8 show that BO on Yumi with SVAE-DC kernel yielded substantial improvement over all baselines. BO in the latent space of SVAE (without dynamic compression) was also able to substantially outperform all baselines, matching SVAE-DC gains after 15 trials.
Figure 9 shows BO results on Franka Emika simulation (left).

Figure 8: BO on ABB Yumi simulation (mean of 50 runs, 90% CIs).

Furthermore, we analyze how increasing the size of SVAE latent space and NNs impacts performance (middle). The larger latent space is D (vs 9D in other experiments), the hidden layer size of NNs is increased from 128 to 256. Larger latent space implies larger search space for BO, which could impair data efficiency. Indeed, we see what BO with SVAE kernel outperforms BBK-KL and SE kernels not as early as before. However, BO with SVAE-DC is able to keep the gains and even decrease the variance between runs (well-performing points are found more reliably). This indicates that dynamic compression could counter-balance increase in kernel dimensionality. Finally, we experimented with Matérn kernel (right plot in Figure 9), but it did not show benefits over using SE kernel. We attempted changing hyperparameter prior and restricting hyperparameter ranges, but it did not consistently outperform random search (same held for SE in high dimensions). The performance of BO with SVAE kernel using Matérn as outer kernel function showed modest improvement over baselines. In contrast, BO with SVAE-DC kernel kept most improvements.

Figure 9: BO with various kernels on Franka Emika simulation. Left: SVAE trained with same parameters as in all the previous experiments. Middle: SVAE with larger latent space and NNs. Right: Matern used as outer function for all kernel. The plots show means over 50 runs, 90% CIs.

8 Conclusion

In this work employed BO to optimize robot controllers with a small budget of trials. Previously, the success of BO has been either limited to low-dimensional controllers or required simulation-based kernels with domain-specific features. We proposed an unsupervised alternative with sequential variational autoencoder. We used it to embed simulated trajectories into a latent space, and to jointly learn relating controllers with latent space paths they induce. Furthermore, we provided a mechanism for dynamic compression, helping BO reject undesirable regions quickly, and explore more in other regions. Our approach yielded ultra-data efficient BO in hardware experiments with hexapod locomotion and a manipulation task, using the same SVAE-DC architecture, training and BO parameters.

This research was supported in part by the Knut and Alice Wallenberg Foundation.


Appendix A: SVAE-DC Modeling Details

The backbone of our model is inspired by hierarchical constructions, like those developed in [30, 41]

. However, these works considered supervised and semi-supervised settings, where a discrete label was associated with each high-dimensional data point (e.g. a label for an image). We are dealing with sequential trajectory data instead, so the internal structure of our data is different. But for the moment let us think about each trajectory as a point in some high-dimensional space. Our idea is to interpret controllers

as continuous ‘labels’ for trajectories

. Then, on a high level, for random variables

we can extend the standard ELBO bound as follows:

Figure 10: Backbone of our SVAE generative model and inference

In the above, denote parameters of the variational approximation, denote the parameters of the generative part of the model. In our work, are weights of deep neural networks. It is customary to drop subscripts indicating NN weight parameters and write for a shorthand notation.

The derivation for the above is similar to [30]. We can also recognize the similarity to a standard ELBO for a simplified model without :

In our case, is observed (we know which controller is executed when we obtain a trajectory ), so there is no further uncertainty about . Also, from the independencies in the model we see that the rest of the variables are independent of given . Hence conditioning is the only modification that appears in . This is why terms like do not appear in our ELBO, but they would have been included if we also had a non-trivial prior . Our construction treats and as observed data, which is in fact what we have available from simulating trajectories. For data collection we can sample controllers at random, since we assume access to a relatively inexpensive simulator (in a sense that it is viable to simulate 100K+ trajectories for training). So we don’t need a sophisticated prior for .

To derive the full SVAE-DC ELBO we can use the decomposition assumptions of the generative model and the approximate posterior:

Generative model:
Approximate posterior:

The 4 terms inside the expectation in Equation 6 above are the 4 neural networks whose parameters will be optimized by gradient ascent to maximize . The choices for their architectures are described in the main paper. For ease of implementation we treat the outputs of as a single latent code , and separate it into components only when needed (e.g. to feed only the part into NN, etc.

One advantage of our formulation is that it is agnostic to whether policies/controllers are stochastic or deterministic, and to whether the simulators used to collect samples are stochastic or deterministic. This is especially convenient, since in robotics deterministic controllers are used widely, while the Reinforcement Learning community frequently considers stochastic policies and environments. With our model: the stochasticity of either environment or controllers (or both) will be encoded in . Even in the case of deterministic controllers and environment (deterministic relationship between and ) the model remains meaningful because of the bottleneck and randomness coming from sampling of during data collection.

One fair question would be: why learn an embedding into lower-dimensional space of path jointly with learning , instead of decomposing the problem into separate dimensionality reduction and modeling stages. For an arbitrary space of paths (either low-dimensional, or even the original high-dimensional space of trajectories) the relationship between and the corresponding probability distribution over the paths would be challenging. This is because it involves the controller properties and the dynamics of the physical environment, both of which are usually highly non-trivial. In the joint model we propose, term can be seen as a ‘regularization’ part of the ELBO. It keeps the latent representation s.t. it is well suited for modeling the relationship between and . The terms pertaining to ‘reconstructing’ original trajectories are the encoder and decoder . Learning progress for these is fast if there is sufficient capacity in the bottleneck . However, if these make fast progress, but learn the space of latent paths that is not easy to relate to the space of controllers – then will drop. Hence ELBO will be lower for this ‘inconvenient’ representation for , encouraging alternatives. Consequently, our joint representation allows not only ‘compressing’ the space of trajectories, but also finding a compression scheme that simplifies the problem of modeling .

As is customary with VAEs, at first we expressed variational approximate posterior and generative model components by multivariate Gaussians with diagonal covariance. Later we found that using Laplace distributions yielded more consistent training results. The reconstruction and generation for successful training runs were comparable. However, some runs using Gaussians collapsed to the mean instead of learning useful latent representations. So we kept Laplace as the default choice.

Appendix B: SVAE-DC Training Visualizations

Below we include visualizations of the training progress. We developed an easy-to-use training pipeline that generates training statistics and visualization videos in Tensorboard. We included our code and a detailed README with instructions on how to install and use the codebase. We took care to comment our implementation, so all further details about our implementation, parameter choices and training procedure would be easy to infer from the code attached to this submission.

Figure 11: SVAE-DC training progress on Daisy. See full description in Figure 12 caption on the next page.
Figure 12: SVAE-DC training progress on Yumi (middle) and Franka Emika (bottom) environments. Observations consist of robot joint angles, object positions and orientations sampled at 500Hz in pybullet simulator. Figures are obtained by visualizing the original (left) reconstructed (middle) and generated (right) state of the robot and objects in the simulator (in this work we are not considering visual observations, so not learning to process pixel data). ‘Bads frac’ indicates what percentage of the original trajectory is spent in undesirable parts of the space (i.e. ). During generation this is obtained by using part of the latent samples as input to NN. For successful BO, perfect fit is not needed. For a useful separation, it is enough for SVAE-DC to fit for bad controllers and to report approximate lower for the good ones.

Appendix C: Parametric vs Intrinsic Dimensionality

When optimizing higher-dimensional controllers with few trials, one could question whether BO with SE kernel should be among the baselines. If our reward functions came from an arbitrary distribution, for BO in 30D space, for example, we would expect to need at least 60 trials to starts seeing the benefits. However, our reward landscapes come from real-world problems, not from purely analytic constructions. While robotics problems have a clear parametric dimensionality, their intrinsic dimensionality is usually unknown. The vision community is familiar with this concept: they frequently refer to a ‘lower-dimensional manifold of real-world images’. The intrinsic dimensionality of vision problems could be orders of magnitude lower than their parametric dimensionality expressed in pixel space.

Figure 13: BO in 30D when only 3 dimensions contribute significantly.

In the context of BO, consider a 30D quadratic: with . Even on this simple quadratic BO with SE kernel gives only modest gains for the first 60 trials. Now consider such that a large number of dimensions do not contribute significantly: . Figure 13 shows that BO with SE kernel succeeds with few trials (as long as hyperparameters do not force BO to over-explore). So SE baseline is a reasonable check for adequate performance in such settings.

In most cases it is difficult to estimate (or even approximately guess) the intrinsic dimensionality of a real-world problem. Parametric representation doesn’t even give an upper bound on complexity. In robotics, intrinsic dimensionality of a problem could be higher than parametric dimensionality of its most commonly used representation. For example, the effects of friction are sometimes abstracted away as a few parameters of a simplified friction model. When such problems are declared ‘low-dimensional’, it creates a misconception that they are ‘easy’. In fact, they remain hard for cases where friction matters for success and a crude model is inadequate. It is also not easy to gauge the complexity of a problem by applying algorithms like PCA on the whole optimization space. A ‘simple’ structure might be characteristic for only a part of the space. For example, failing controllers could exhibit near chaotic behavior, making have high intrinsic dimensionality when considering the whole space. But this space might contain sub-regions, where the relationship between reward and change in controller parameters is gradual. If domain knowledge or informed kernels can help find a few points close to a successful region: the gains for BO could be paramount. BO could quickly focus exploration on the promising regions, without being restricted to a particular model or simulator structure that originally helped to point to a promising part of the space.