L EARNING T RANSFERABLE M OTOR S KILLS WITH H IERARCHICAL L ATENT M IXTURE P OLICIES
A BSTRACT
For robots operating in the real world it is desirable to learn reusable behaviours that can effectively be transferred and adapted to numerous tasks and scenarios
We propose an approach to learn abstract motor skills from data using a hierarchical mixture latent variable model.
In contrast to existing work, our method exploits a three-level hierarchy of both discrete and continuous latent variables, to capture a set of high-level behaviours while allowing for variance in how they are executed.
We demonstrate in manipulation domains that the method can effectively cluster ofﬂine data into distinct, executable behaviours while retaining the ﬂexibility of a continuous latent variable model.
The resulting skills can be transferred and ﬁne-tuned on new tasks, unseen objects and from state to vision-based policies, yielding better sample efﬁciency and asymptotic performance compared to existing skill- and imitation-based methods.
We further analyse how and when the skills are most beneﬁcial: they encourage directed exploration to cover large regions of the state space relevant to the task, making them most effective in challenging sparse-reward settings
I NTRODUCTION
Reinforcement learning is a powerful and ﬂexible paradigm to train embodied agents, but relies on large amounts of agent experience, computation, and time, on each individual task.
Learning each task from scratch is inefﬁcient: it is desirable to learn a set of skills that can efﬁciently be reused and adapted to related downstream tasks.
This is particularly pertinent for real-world robots, where interaction is expensive and data-efﬁciency is crucial.
There are numerous existing approaches to learn transferable embodied skills, usually formulated as a two-level hierarchy with a high-level controller and low-level skills.
These methods predominantly represent skills as being either continuous, such as goal-conditioned (Lynch et al., 2019;
Pertsch et al., 2020b) or latent space policies (Haarnoja et al., 2018; Merel et al., 2019; Singh et al., 2021); or discrete, such as mixture or option-based methods (Sutton et al., 1999; Daniel et al., 2012; Florensa et al., 2017; Wulfmeier et al., 2021).
Our goal is to combine these perspectives to leverage their complementary advantages.
We propose an approach to learn a three-level skill hierarchy from an ofﬂine dataset, capturing both discrete and continuous variations at multiple levels of behavioural abstraction.
The model comprises a low-level latent-conditioned controller that can learn motor primitives, a set of continuous latent mid-level skills, and a discrete high-level controller that can compose and select among these abstract mid-level behaviours.
Since the mid- and high-level form a mixture, we call our method
Hierarchical Latent Mixtures of Skills (HeLMS).
We demonstrate on challenging object manipulation tasks that our method can decompose a dataset into distinct, intuitive, and reusable behaviours.
We show that these skills lead to improved sample efﬁciency and performance in numerous transfer scenarios: reusing skills for new tasks, generalising across unseen objects, and transferring from state to vision-based policies.
Further analysis and ablations reveal that both continuous and discrete components are beneﬁcial, and that the learned hierarchical skills are most useful in sparse-reward settings, as they encourage directed exploration of task-relevant parts of the state space.
Our main contributions are as follows:
• We propose a novel approach to learn skills at different levels of abstraction from an ofﬂine dataset.
The method captures both discrete behavioural modes and continuous variation using a hierarchical mixture latent variable model.
• We present two techniques to reuse and adapt the learned skill hierarchy via reinforcement learning in downstream tasks, and perform extensive evaluation and benchmarking in different transfer settings: to new tasks and objects, and from state to vision-based policies.
• We present a detailed analysis to interpret the learned skills, understand when they are most beneﬁcial, and evaluate the utility of both continuous and discrete skill representations.
R ELATED WORK
A long-standing challenge in reinforcement learning is the ability to learn reusable motor skills that can be transferred efﬁciently to related settings.
One way to learn such skills is via multi-task reinforcement learning (Heess et al., 2016; James et al., 2018;
Hausman et al., 2018; Riedmiller et al., 2018), with the intuition that behaviors useful for a given task should aid the learning of related tasks.
However, this often requires careful curation of the task set, where each skill represents a separate task.
Some approaches avoid this by learning skills in an unsupervised manner using intrinsic objectives that often maximize the entropy of visited states while keeping skills distinguishable (Gregor et al., 2017;
Eysenbach et al., 2019; Sharma et al., 2019; Zhang et al., 2020).
A large body of work explores skills from the perspective of unsupervised segmentation of repeatable behaviours in temporal data (Niekum & Barto, 2011; Ranchod et al., 2015; Kr ¨ uger et al., 2016;
Lioutikov et al., 2017; Shiarlis et al., 2018; Kipf et al., 2019; Tanneberg et al., 2021).
Other works investigate movement or motor primitives that can be selected or sequenced together to solve complex manipulation or locomotion tasks (M ¨ ulling et al., 2013; Rueckert et al., 2015; Lioutikov et al., 2015; Paraschos et al., 2018; Merel et al., 2020; Tosatto et al., 2021;
Dalal et al., 2021).
Some of these methods also employ mixture models to jointly model low-level motion primitives and a high-level primitive controller (Muelling et al., 2010; Colom ´ e & Torras, 2018; Pervez & Lee, 2018); the high-level controller can also be implicit and decentralised over the low-level primitives (Goyal et al., 2019).
Several existing approaches employ architectures in which the policy is comprised of two (or more) levels of hierarchy.
Typically, a low-level controller represents the learned set of skills, and a high-level policy instructs the low-level controller via a latent variable or goal.
Such latent variables can be discrete (Florensa et al., 2017; Wulfmeier et al., 2020) or continuous (Nachum et al., 2018;
Haarnoja et al., 2018) and regularization of the latent space is often crucial (Tirumala et al., 2019).
The latent variable can represent the behaviour for one timestep, for a ﬁxed number of timesteps (Ajay et al., 2021), or options with different durations (Sutton et al., 1999; Bacon et al., 2017; Wulfmeier et al., 2021).
One such approach that is particularly relevant (Florensa et al., 2017) learns a diverse set of skills, via a discrete latent variable that interacts multiplicatively with the state to enable continuous variation in a Stochastic Neural Network policy; this skill space is then transferred to locomotion tasks by learning a new categorical controller.
Our method differs in a few key aspects: our proposed three-level hierarchical architecture explicitly models abstract discrete skills while allowing for temporal dependence and lower-level latent variation in their execution, enabling diverse object-centric behaviours in challenging manipulation tasks.
Our work is related to methods that learn robot policies from demonstrations (LfD, e.g. (Rajeswaran et al., 2018;
Shiarlis et al., 2018; Strudel et al., 2020)) or more broadly from logged data (ofﬂine
RL, e.g. (Wu et al., 2019; Kumar et al., 2020; Wang et al., 2020)).
While many of these focus on learning single-task policies, several approaches learn skills ofﬂine that can be transferred online to new tasks (Merel et al., 2019; Lynch et al., 2019;
Pertsch et al., 2020a; Ajay et al., 2021; Singh et al., 2021).
These all train a two-level hierarchical model, with a high-level encoder that maps to a continuous latent space, and a low-level latent-conditioned controller.
The high-level encoder can encode a whole trajectory (Pertsch et al., 2020a; 2021; Ajay et al., 2021); a short look-ahead state sequence (Merel et al., 2019); the current and ﬁnal goal state (Lynch et al., 2019); or can even be simple isotropic Gaussian noise (Singh et al., 2021) that can be ﬂexibly transformed by a ﬂow-based low-level controller.
At transfer time, a new high-level policy is learned from scratch: this can be more efﬁcient with skill priors (Pertsch et al., 2020a) or temporal abstraction (Ajay et al., 2021). [Figure]
HeLMS builds on this large body of work by explicitly modelling both discrete and continuous behavioural structure via a three-level skill hierarchy.
We use similar information asymmetry to
Neural Probabilistic Motor Primitives (NPMP) (Merel et al., 2019; 2020), conditioning the highlevel encoder on a short look-ahead trajectory.
However HeLMS explicitly captures discrete modes of behaviour via the high-level controller, and learns an additional mid-level which is able to transfer abstract skills to downstream tasks, rather than learning a continuous latent policy from scratch.
M ETHOD
This paper examines a two-stage problem setup: an ofﬂine stage where a hierarchical skill space is learned from a dataset, and an online stage where these skills are transferred to a reinforcement learning setting.
The dataset D comprises a set of trajectories, each a sequence of state-action pairs { x t , a t } Tt =0 .
The model incorporates a discrete latent variable y t ∈ { 1 , . .
, K } as a high-level skill selector (for a ﬁxed number of skills K ), and a mid-level continuous variable z t ∈ R n z conditioned on y t which parameterises each skill.
Marginally, z t is then a latent mixture distribution representing both a discrete set of skills and the variation in their execution.
A sample of z t represents an abstract behaviour, which is then executed by a low-level controller p ( a t | z t , x t ) .
The learned skill space can then be transferred to a reinforcement learning agent π in a Markov Decision Process deﬁned by tuple {S , A , T , R , γ } : these represent the state, action, and transition distributions, reward function, and discount factor respectively.
When transferring, we train a new high-level controller that acts either at the level of discrete skills y t or continuous z t , and freeze lower levels of the policy.
We explain our method in detail in the following sections.
3. L ATENT M IXTURE S KILL S PACES FROM O FFLINE D ATA
Our method employs the generative model in Figure 1a.
As shown, the state inputs can be different for each level of the hierarchy, but to keep notation uncluttered, we refer to all state inputs as x t and the speciﬁc input can be inferred from context.
The joint distribution of actions and latents over a trajectory is decomposed into a latent prior p ( y 0: T , z 1: T ) and a low-level controller p ( a t | z t , x t ) :
[Equation]
Intuitively, the categorical variable y t can capture discrete modes of behaviour, and the continuous latent z t is conditioned on this to vary the execution of each behaviour.
Thus, z t follows a mixture distribution, encoding all the relevant information on desired abstract behaviour for the low-level controller p ( a t | z t , x t ) .
Since each categorical latent y t is dependent on y t − 1 , and z t is only dependent on y t , this prior can be thought of as a Hidden Markov model over the sequence of z 1: T .
To perform inference over the latent variables, we introduce the variational approximation:
[Equation]
Here, the selection of a skill y t ∼ q ( y t | y t − 1 , x t ) is dependent on that of the previous timestep (allowing for temporal consistency), as well as the input.
The mid-level skill is then parameterised by z t ∼ q ( z t | y t , x t ) based on the chosen skill and current input.
p ( y 0 ) and p ( y t | y t − 1 ) model a skill prior and skill transition prior respectively, while p ( z t | y t ) represents a skill parameterisation prior to regularise each mid-level skill.
While all of these priors can be learned in practice, we only found it necessary to learn the transition prior, with a uniform categorical for the initial skill prior and a simple ﬁxed N (0 , I ) prior for p ( z t | y t ) .
Training via the Evidence Lower Bound
The proposed model contains a number of components with trainable parameters: the prior parameters ψ = { ψ a , ψ y } for the low-level controller and categorical transition prior respectively; and posterior parameters φ = { φ y , φ z } for the high-level controller and mid-level skills.
For a trajectory { x 1: T , a 1: T } ∼ D , we can compute the Evidence Lower Bound for the state-conditional action distribution, ELBO ≤ p ( a 1: T | x 1: T ) , as follows:
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
where ˜ z { y t } t ∼ q ( z t | y t , x t ) .
The coefﬁcients β y and β z can be used to weight the KL terms, and the cumulative component probability q ( y t | x 1: t ) can be computed iteratively as q ( y t | x 1: t )
= (cid:80) y t − 1 q φ y
( y t | y t − 1 , x t ) q ( y t − 1 | x 1: t − 1 ) .
In other words, for each timestep t and each mixture component, we compute the latent sample and the corresponding action log-probability, and the
KL-divergence between the component posterior and prior.
This is then marginalised over all y t , with an additional KL over the categorical transitions.
For more details, see Appendix C.
Information-asymmetry As noted in previous work (Tirumala et al., 2019; Galashov et al., 2019), hierarchical approaches often beneﬁt from information-asymmetry, with higher levels seeing additional context or task-speciﬁc information.
This ensures that the high-level remains responsible for abstract, task-related behaviours, while the low-level executes simpler motor primitives.
We employ similar techniques in HeLMS: the low-level inputs x LL comprise the proprioceptive state of the embodied agent; the mid-level inputs x ML also include the poses of objects in the environment; and the high-level x HL concatenates both object and proprioceptive state for a short number of lookahead timesteps.
The high- and low-level are similar to (Merel et al., 2019), with the low-level controller enabling motor primitives based on proprioceptive information, and the high-level using the lookahead information to provide additional context regarding behavioural intent when specifying which skill to use.
The key difference is the categorical high-level and the additional mid-level, with which
HeLMS can learn more object-centric skills and transfer these to downstream tasks.
Network architectures The architecture and information ﬂow in HeLMS are shown in Figure 1b.
The high-level network contains a gated head , which uses the previous skill y t − 1 to index into one of
K categorical heads, each of which specify a distribution over y t .
For a given y t , the corresponding mid-level skill network is selected and used to sample a latent action z t , which is then used as input for the latent-conditioned low-level controller, which parameterises the action distribution.
The skill transition prior p ( y t | y t − 1 ) is also learned, and is parameterised as a linear softmax layer which takes in a one-hot representation of y t − 1 and outputs the distribution over y t .
All components are trained end-to-end via the objective in Equation 3.
3. R EINFORCEMENT LEARNING WITH RELOADED SKILLS
Once learned, we propose two methods to transfer the hierarchical skill space to downstream tasks.
Following previous work (e.g. (Merel et al., 2019; Singh et al., 2021)), we freeze the low-level controller p ( a t | z t , x t ) , and learn a policy for either the continuous ( z t ) or discrete ( y t ) latent.
Categorical agent One simple and effective technique is to additionally freeze the mid-level components q ( z t | y t , x t ) , and learn a categorical high-level controller π ( y t | x t ) for the downstream task.
The learning objective is given by:
[Equation]
where the standard discounted return objective in RL is augmented by an additional term performing
KL-regularisation to some prior π 0 scaled by coefﬁcient η y .
This could be any categorical distribution such as the previously learned transition prior p
( y t | y t − 1 ) , but in this paper we regularise to the uniform categorical prior to encourage diversity.
While any RL algorithm could be used to optimize π ( y t | x t ) , in this paper we use MPO (Abdolmaleki et al., 2018) with a categorical action distribution (see Appendix B for details).
We hypothesise that this method improves sample efﬁciency by converting a continuous control problem into a discrete abstract action space, which may also aid in credit assignment.
However, since both the mid-level components and low-level are frozen, it can limit ﬂexibility and plasticity, and also requires that all of the mid- and low-level input states are available in the downstream task.
We call this method HeLMS-cat .
Mixture agent A more ﬂexible method of transfer is to train a latent mixture policy, π ( z t | x t ) =
[Equation]
y t π ( y t | x t ) π ( z t | y t , x t ) .
In this case, the learning objective is given by:
[Equation]
where in addition to the categorical prior, we also regularise each mid-level skill to a corresponding prior π 0 ( z t | y t , x t ) .
While the priors could be any policies, we set them to be the skill posteriors q ( z t | y t , x t ) learned ofﬂine, to ensure the mixture components remain close to the pre-learned skills.
This is related to (Tirumala et al., 2019), which also applies KL-regularisation at multiple levels of a hierarchy.
While the high-level controller π ( y t | x t ) is learned from scratch, the mixture components can also be initialised to q ( z t | y t , x t ) , to allow for initial exploration over the space of skills.
Alternatively, the mixture components can use different inputs, such as vision: this setup allows vision-based skills to be learned efﬁciently by regularising to state-based skills learned ofﬂine.
We optimise this using RHPO (Wulfmeier et al., 2020), which employs a similar underlying optimisation to MPO for mixture policies (see Appendix B for details).
We call this HeLMS-mix .
E XPERIMENTS
Our experiments focus on the following questions: (1) Can we learn a hierarchical latent mixture skill space of distinct, interpretable behaviours?
(2) How do we best reuse this skill space to improve sample efﬁciency and performance on downstream tasks?
(3) Can the learned skills transfer effectively to multiple downstream scenarios: (i) different objects; (ii) different tasks; and (iii) different modalities such as vision-based policies?
(4) How exactly do these skills aid learning of downstream manipulation tasks?
Do they aid exploration?
Are they useful in sparse or dense reward scenarios?
4. E XPERIMENTAL SETUP
Environment and Tasks We focus on manipulation tasks, using a MuJoCo-based environment with a single Sawyer arm, and three objects coloured red, green, and blue.
We follow the challenging object stacking benchmark of Lee et al.
(2021), which speciﬁes ﬁve object sets (Figure 2), carefully designed to have diverse geometries and present different challenges for a stacking agent.
These range from simple rectangular objects (object set 4), to geometries such as slanted faces (setsand 2) that make grasping or stacking the objects more challenging.
This environment allows us [Figure] [Figure] to systematically evaluate generalisation of manipulation behaviours for different tasks interacting with geometrically different objects.
For further information, we refer the reader to Appendix D.1 or to (Lee et al., 2021).
Details of the rewards for the different tasks are also provided in Appendix F.
Datasets To evaluate our approach and baselines in the manipulation settings, we use two datasets:
• red_on_blue_stacking : this data is collected by an agent trained to stack the red object on the blue object and ignore the green one, for the simplest object set, set4.
all_pairs_stacking : similar to the previous case, but with all six pairwise stacking combinations of { red, green, blue } , and covering all of the ﬁve object sets.
Baselines For evaluation in transfer scenarios, we compare HeLMS with a number of baselines:
• From scratch :
We learn the task from scratch with MPO, without an ofﬂine learning phase.
• NPMP+KL : We compare against NPMP (Merel et al., 2019), which is the most similar skill-based approach in terms of information-asymmetry and policy conditioning.
We make some small changes to the originally proposed method, and also apply additional KL-regularisation to the latent prior: we found this to improve performance signiﬁcantly in our experiments.
For more details and an ablation, see Appendix A.2.
• Behaviour Cloning (BC) : We apply behaviour cloning to the dataset, and ﬁne-tune this policy via MPO on the downstream task.
While the actor is initialised to the solution obtained via BC, the critic still needs to be learned from scratch.
• Hierarchical BC : We evaluate a hierarchical variant of BC with a similar latent space z to NPMP using a latent Gaussian high-level controller.
However, rather than freezing the low-level and learning just a high-level policy, Hierarchical BC ﬁne-tunes the entire model.
• Asymmetric actor-critic :
For state-to-vision transfer, HeLMS uses prior skills that depend on object states to learn a purely vision-based policy.
Thus, we also compare against a variant of MPO with an asymmetric actor-critic (Pinto et al., 2017) setup, which uses object states differently: to speed up learning of the critic, while still learning a vision-based actor.
4. L EARNING SKILLS FROM OFFLINE DATA
We ﬁrst aim to understand whether we can learn a set of distinct and interpretable skills from data (question (1)).
For this, we train HeLMS on the red_on_blue_stacking dataset with 5 skills.
[Figure] [Figure] Figure 3a shows some example episode rollouts when the learned hierarchical agent is executed in the environment, holding the high-level categorical skill constant for an episode.
Each row represents a different skill component, and the resulting behaviours are both distinct and diverse: for example, a lifting skill (row 1) where the gripper closes and rises up, a reaching skill (row 2) where the gripper moves to the red object, or a grasping skill (row 3) where the gripper lowers and closes its ﬁngers.
Furthermore, without explicitly encouraging this, the emergent skills capture temporal consistency: Figure 3b shows the learned prior p ( y t | y t − 1 ) (visualised as a transition matrix) assigns high probability along the diagonal (remaining in the same skill).
Finally, Figure 3c demonstrates that all skills are used, without degeneracy.
4. T RANSFER TO DOWNSTREAM TASKS
Generalising to different objects We next evaluate whether the previously learned skills (i.e. trained on the simple objects in set 4) can effectively transfer to more challenging object interaction scenarios: the other four object sets proposed by (Lee et al., 2021).
The task uses a sparse staged reward, with reward incrementally given after completing each sub-goal of the stacking task.
As shown in Figure 4, both variants of HeLMS learn signiﬁcantly faster than baselines on the different object sets.
Compared to the strongest baseline (NPMP), HeLMS reaches better average asymptotic performance (and much lower variance) on two object sets (1 and 3), performs similarly on set 5, and does poorer on object set 2.
The performance on object set 2 potentially highlights a trade-off between incorporating higher-level abstract behaviours and maintaining low-level ﬂexibility: this object set often requires a reorientation of the bottom object due to its slanted faces, a behaviour that is not common in the ofﬂine dataset, which might require greater adaptation of mid- and low-level skills.
This is an interesting investigation we leave for future work.
Compositional reuse of skills To evaluate whether the learned skills are composable for new tasks, we train HeLMS on the all_pairs_stacking dataset with 10 skills, and transfer to a pyramid task.
In this setting, the agent has to place the red object adjacent to the green object, and stack the blue object on top to construct a pyramid.
The task is speciﬁed via a sparse staged reward [Figure] for each stage or sub-task: reaching, grasping, lifting, and placing the red object, and subsequently the blue object.
In Figure 5(a), we plot the performance of both variants of our approach, as well as
NPMP and MPO; we omit the BC baselines as this involves transferring to a fundamentally different task.
Both HeLMS-mix and HeLMS-cat reach a higher asymptotic performance than both NPMP and MPO, indicating that the learned skills can be better transferred to a different task.
We show an episode rollout in Figure 5(b) in which the learned agent can successfully solve the task.
From state to vision-based policies While our method learns skills from proprioception and object state, we evaluate whether these skills can be used to more efﬁciently learn a vision-based policy.
This is invaluable for practical real-world scenarios, since the agent acts from pure visual observation at test time without requiring privileged and often difﬁcult-to-obtain object state information.
We use the HeLMS-mix variant to transfer skills to a vision-based policy, by reusing the low-level controller, initialising a new high-level controller and mid-level latent skills (with vision and proprioception as input), and KL-regularising these to the previously learned state-based skills.
While the learned policy is vision-based, this KL-regularisation still assumes access to object states during training.
For a fair comparison, we additionally compare our approach with a version of MPO using an asymmetric critic (Pinto et al., 2017), which exploits object state information instead of vision in the critic, and also use this for HeLMS.
As shown in Figure 6, learning a vision-based policy with
MPO from scratch is very slow and computationally intensive, but an asymmetric critic signiﬁcantly speeds up learning, supporting the empirical ﬁndings of Pinto et al.
However, HeLMS once again demonstrates better sample efﬁciency, and reaches slightly better asymptotic performance.
We note that this uses the same ofﬂine model as for the object generalisation experiments, showing that the same state-based skill space can be reused in numerous settings, even for vision-based tasks.
4. W HERE AND HOW CAN HIERARCHICAL SKILL REUSE BE EFFECTIVE ?
Sparse reward tasks We ﬁrst investigate how HeLMS performs for different rewards: a dense shaped reward, the sparse staged reward from the object generalisation experiments, and a fully sparse reward that is only provided after the agent stacks the object.
For this experiment, we use the skill space trained on red_on_blue_stacking and transfer it to the same RL task of stacking on object set 4.
The results are shown in Figure 7.
With a dense reward (and no object transfer required), all of the approaches can successfully learn the task.
With the sparse staged reward, the baselines all plateau at a lower performance, with the exception of NPMP, as previously discussed.
However, for the challenging fully-sparse scenario, HeLMS is the only method that achieves nonzero reward.
This neatly illustrates the beneﬁt of the proposed hierarchy of skills: it allows for directed exploration which ensures that even sparse rewards can be encountered.
This is consistent with observations from prior work in hierarchical reinforcement learning (Florensa et al., 2017;
Nachum et al., 2019), and we next investigate this claim in more depth for our manipulation setting.
Exploration To measure whether the proposed approach leads to more directed exploration, we record the average coverage in state space at the start of RL (i.e. zero-shot transfer).
This is computed as the variance (over an episode) of the state x t , separated into three interpretable groups: [Table] [Figure] joints (angles and velocity), grasp (a simulated grasp sensor), and object poses.
We also record the total reward (dense and sparse staged).
The results are reported in Table 1.
While all approaches achieve some zero-shot dense reward (with BC the most effective), HeLMS 1 receives a sparse staged reward an order of magnitude greater.
Further, in this experiment we found it was able to achieve the fully sparse reward (stacked) in one episode.
Analysing the state coverage results, while other methods are able to cover the joint space more (e.g. by randomly moving the joints), HeLMS is nearly two orders of magnitude higher for grasp states.
This indicates the utility of hierarchical skills: by acting over the space of abstract skills rather than low-level actions, HeLMS performs directed exploration and targets particular states of interest, such as grasping an object.
4. A BLATION S TUDIES
Capturing continuous and discrete structure To evaluate the beneﬁt of both continuous and discrete components, we train our method with a ﬁxed variance of zero for each latent component (i.e.
‘discrete-only’) and transfer to the stacking task with sparse staged reward in an easy case (object set 4) and hard case (object set 3), as shown in Figure 8(a) and (b).
We also evaluate the ‘continuousonly’ case with just a single Gaussian to represent the high- and mid-level skills: this is equivalent to the NPMP+KL baseline.
We observe the the discrete component alone leads to improved sample efﬁciency in both cases, but modelling both discrete and continuous latent behaviours makes a signiﬁcant difference in the hard case.
In other words, when adapting to challenging objects, it is important to capture discrete skills, but allow for latent variation in how they are executed.
KL-regularisation We also perform an ablation for KL-regularisation during the ofﬂine phase (via β z ) and online RL (via η z ), to gauge the impact on transfer; see Appendix A.1 for details.
C ONCLUSION
We present HeLMS, an approach to learn transferable and reusable skills from ofﬂine data using a hierarchical mixture latent variable model.
We analyse the learned skills to show that they effectively cluster data into distinct, interpretable behaviours.
We demonstrate that the learned skills can be ﬂexibly transferred to different tasks, unseen objects, and to different modalities (such as from state to vision).
Ablation studies indicate that it is beneﬁcial to model both discrete modes and continuous variation in behaviour, and highlight the importance of KL-regularisation when transferring to RL and ﬁne-tuning the entire mixture of skills.
We also perform extensive analysis to understand where and how the proposed skill hierarchy can be most useful:
we ﬁnd that it is particularly invaluable in sparse reward settings due to its ability to perform directed exploration.
There are a number of interesting avenues for future work.
While our model demonstrated temporal consistency, it would be useful to more actively encourage and exploit this for sample-efﬁcient transfer.
It would also be useful to extend this work to better ﬁne-tune lower level behaviours, to allow for ﬂexibility while exploiting high-level behavioural abstractions. A CKNOWLEDGMENTS
The authors would like to thank Coline Devin for detailed comments on the paper and for generating the all_pairs_stacking dataset.
We would also like to thank Alex X. Lee and Konstantinos
Bousmalis for help with setting up manipulation experiments.
We are also grateful to reviewers for their feedback
A PPENDIX A A DDITIONAL EXPERIMENTS A. A BLATIONS FOR KL- REGULARISATION
In these experiments, we investigate the effect of KL-regularisation on the mid-level components, both for the ofﬂine learning phase (regularising each component to p ( z t | y t ) =
N (0 , I ) via coefﬁcient β z ), and the online reinforcement learning stage via HeLMS-mix (regularising each component to the mid-level skills learned ofﬂine, via coefﬁcient η z )).
The results are reported in Figure 9, where each plot represents a different setting for ofﬂine KL-regularisation (either regularisation to N (0 , I ) with β z = 0 .
01 , or no regularisation with β z = 0 ) and a different transfer case (the easy case of transferring to object set 4, or the hard case of transferring to object set 3).
Each plot shows the downstream performance when varying the strength of KL-regularisation during RL via coefﬁcient η z .
The HeLMS-cat approach represents the extreme case where the skills are entirely frozen (i.e. full regularisation).
The results suggest some interesting properties of the latent skill space based on regularisation.
When regularising the mid-level components to the N (0 , I ) prior, it is important to regularise during online RL; this is especially true for the hard transfer case, where HeLMS-cat performs much better, and the performance degrades signiﬁcantly with lower regularisation values.
However, when removing mid-level regularisation during ofﬂine learning, the method is insensitive to regularisation during RL over the entire range evaluated, from 0 .
01 to 100 . 0 .
We conjecture that with mid-level skills regularised to N (0 , I ) , the different mid-level skills are drawn closer together and occupy a more compact region in latent space, such that KL-regularisation is necessary during RL for a skill to avoid drifting and overlapping with the latent distribution of other skills (i.e. skill degeneracy).
In contrast, without ofﬂine KL-regularisation, the skills are free to expand and occupy more distant regions of the latent space, rendering further regularisation unnecessary during RL.
Such latent space properties could be further analysed to improve learning and transfer of skills; we leave this as an interesting direction for future work. [Figure]
A. NPMP ABLATION
The Neural Probabilistic Motor Primitives (NPMP) work (Merel et al., 2019) presents a strong baseline approach to learning transferable motor behaviours, and we run ablations to ensure a fair comparison to the strongest possible result.
As discussed in the main text, NPMP employs a Gaussian high-level latent encoder with a AR (1) prior in the latent space.
We also try a ﬁxed N (0 , I ) prior (this is equivalent to an AR (1) prior with a coefﬁcient of 0 , so can be considered a hyperparameter choice).
Since our method beneﬁts from KL-regularisation during RL, we apply this to NPMP as well.
As shown in Figure 10, we ﬁnd that both changes lead to substantial improvements in the manipulation domain, on all ﬁve object sets.
Consequently, in our main experiments, we report results with the best variant, using a N (0 , I ) prior with KL-regularisation during RL.
[Figure]
We ﬁnd that using N (0 , I ) prior with KL-regularisation performs much better in the manipulation domain compared to the original AR (1) prior, so we use this modiﬁed baseline.
B R EINFORCEMENT LEARNING WITH MPO AND RHPO
As discussed in Section 3.2, the hierarchy of skills are transferred to RL in two ways: HeLMScat, which learns a new high-level categorical policy π ( y t | x t ) via MPO (Abdolmaleki et al., 2018); or HeLMS-mix, which learns a mixture policy π ( z t | x t ) = (cid:80)
y t π ( y t | x t ) π ( z t | y t , x t ) via
RHPO (Wulfmeier et al., 2020).
We describe the optimisation for both of these cases in the following subsections.
For clarity of notation, we omit the additional KL-regularisation terms introduced in Section 3.2 and describe just the base methods of MPO and RHPO when applied to the RL setting in this paper.
These KL-terms are incorporated as additional loss terms in the policy improvement stage.
B. H E LMS- CAT VIA MPO
Maximum a posteriori Policy Optimisation (MPO) is an Expectation-Maximisation-based algorithm that performs off-policy updates in three steps: (1) updating the critic; (2) creating a non-parametric intermediate policy by weighting sampled actions using the critic; and (3) updating the parametric policy to ﬁt the critic-reweighted non-parametric policy, with trust region constraints to improve stability.
We detail each of these steps below.
Note that while the original MPO operates in the environment’s action space, we use it here for the high-level controller, to set the categorical variable y t .
Policy evaluation First, the critic is updated via a TD(0) objective as:
[Equation]
[Equation]
Here, Q T =
r t + γ E x t
+1 , y t +1 [ Q (cid:48) ( s t +1 , y t +1 )] is the 1 -step target with the state transition ( x t , y t , x t +1 ) returned from the replay buffer B , and next action sampled from y t +1 ∼ π (cid:48)
( ·| x t +1 ) .
π (cid:48) and Q (cid:48) are target networks for the policy and the critic, used to stabilise learning.
Policy improvement Next, we proceed with the ﬁrst step of policy improvement by constructing an intermediate non-parametric policy q ( y t | x t ) , and optimising the following constrained objective:
[Equation]
where (cid:15) E deﬁnes a bound on the KL divergence between the non-parametric and parametric policies at the current learning step k .
This constrained optimisation problem has the following closed-form solution:
[Equation]
In other words, this step constructs an intermediate policy which reweights samples from the previous policy using exponentiated temperature-scaled critic values.
The temperature parameter η is derived based on the dual of the Lagrangian; for futher details please refer to (Abdolmaleki et al., 2018).
Finally, we can ﬁt a parametric policy to the non-parametric distribution q ( y t | x t ) by minimising their KL-divergence, subject to a trust-region constraint on the parametric policy:
[Equation]
This optimisation problem can be solved via Lagrangian relaxation, with the Lagrangian multiplier (cid:15) M modulating the strength of the trust-region constraint.
For further details and full derivations, please refer to (Abdolmaleki et al., 2018).
B. H E LMS- MIX VIA RHPO
RHPO (Wulfmeier et al., 2020) follows a similar optimisation procedure as MPO, but extends it to mixture policies and multi-task settings.
We do not exploit the multi-task capability in this work, but utilise RHPO to optimise the mixture policy in latent space, π ( z t | x t ) =
(cid:80)
y t π ( y t | x t ) π ( z t | y t , x t ) .
The Q-function Q φ ( x t , z t ) and parametric policy π θ k
( z t | x t ) use the continuous latents z t as actions instead of the categorical y t .
This is also in contrast to the original formulation of RHPO, which uses the environment’s action space.
Compared to MPO, the policy improvement stage of the non-parametric policy is minimally adapted to take into account the new mixture policy.
The key difference is in the parametric policy update step, which optimises the following:
[Equation]
In other words, separate trust-region constraints are applied to a sum of KL-divergences: for the high-level categorical and for each of the mixture components.
Following the original RHPO, we separate the single constraint into decoupled constraints that set a different (cid:15) for the means, covariances, and categorical ( (cid:15) µ , (cid:15) σ , and (cid:15) cat , respectively).
This allows the optimiser to independently modulate how much the categorical distribution, component means, and component variances can change.
For further details and full derivations, please refer to (Wulfmeier et al., 2020).
C ELBO DERIVATION AND INTUITIONS
We can compute the Evidence Lower Bound for the state-conditional action distribution, p ( a 1: T | x 1: T ) ≥ ELBO , as follows:
[Equation]
We note that the ﬁrst two terms in the expectation depend only on timestep t , so we can simplify and marginalise exactly over all discrete { y 1: T }\ y t .
For the ﬁnal term, we note that the KL at timestep t is constant with respect to y t (as it already marginalises over the whole distribution), and only depends on y t − 1 .
Lastly, we will use sampling to approximate the expectation over z t .
This yields the following:
[Equation]
ELBO
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table] [Equation] [Table] [Equation]
[Table]
[Equation]
where ˜ z { y t } t ∼ q ( z t | y t , x t ) , the coefﬁcients β y and β z can be used to weight the KL terms, and the cumulative component probability q ( y t | x 1: t ) can be computed iteratively as:
[Equation]
In other words, for each timestep t and each mixture component, we compute the latent sample and the corresponding action log-probability, and the KL-divergence between the component posterior and prior.
This is then marginalised over all y t , with an additional KL over the categorical transitions.
Structuring the graphical model and ELBO in this form has a number of useful properties.
First, the
ELBO terms include an action reconstruction loss and KL term for each mixture component, scaled by the posterior probability of each component given the history.
For a given state, this pressures the model to assign higher posterior probability to components that have low reconstruction cost or
KL, which allows different components to specialise for different parts of the state space.
Second, the categorical KL between posterior and prior categorical transition distributions is scaled by the posterior probability of the previous component given history q ( y t − 1 | x 1: t − 1 ) : this allows the relative probabilities of past skill transitions along a trajectory to be considered when regularising the current skill distribution.
Finally, this formulation does not require any sampling or backpropagation through the categorical variable: starting from t = 0 , the terms for each timestep can be efﬁciently computed by recursively updating the posterior over components given history ( q ( y t | x 1: t ) ), and summing over all possible categorical values at each timestep.
D E NVIRONMENT PARAMETERS
As discussed earlier in the paper, all experiments take place in a MuJoCo-based object manipulation environment using a Sawyer robot manipulator and three objects: red, green, and blue.
The state variables in the Sawyer environment are shown in Table 3.
All state variables are stacked for 3 frames for all agents.
The object states are only provided to the mid-level and high-level for HeLMS runs, and the camera images are only used by the high- and mid-level controller in the vision transfer experiments (without object states).
The action space is also shown in Table 4.
Since the action dimensions vary signiﬁcantly in range, they are normalised to be between [ − 1 , 1] for all methods during learning.
When learning via RL, we apply domain randomisation to physics (but not visual randomisation), and a randomly sampled action delay of 0-2 timesteps.
This is applied for all approaches, and ensures that we can learn a policy that is robust to small changes in the environment.
[Table] [Table]
D. O BJECT SETS
As discussed in the main paper, we use the object sets deﬁned by Lee et al.
(2021), which are carefully designed to cover different object geometries and affordances, presenting different challenges for object interaction tasks.
The object sets are shown in Figure 11 (the image has been taken directly from (Lee et al., 2021) for clarity), and feature both simulated and real-world versions; in this paper we focus on the simulated versions.
As discussed in detail by (Lee et al., 2021), each object set has a different degree of difﬁculty and presents a different challenge to the task of stacking red-on-blue:
• In object set 1, the red object has slanted surfaces that make it difﬁcult to grasp, while the blue object is an octagonal prism that can roll.
• In object set 2, the blue object has slanted surfaces, such that the red object will likely slide off unless the blue object is ﬁrst reoriented.
• In object set 3, the red object is long and narrow, requiring a precise grasp and careful placement.
• Object set 4 is the easiest case with rectangular prisms for both red and blue.
• Object set 5 is also relatively easy, but the blue object has ten faces, meaning limited surface area for stacking.
For more details about the object sets and the rationale behind their design, we refer the reader to (Lee et al., 2021).
E N ETWORK ARCHITECTURES AND HYPERPARAMETERS
The network architecture details and hyperparameters for HeLMS are shown in Table 5.
Parameter sweeps were performed for the β coefﬁcients during ofﬂine learning and the η coefﬁcients during
RL.
Small sweeps were also performed for the RHPO (cid:15) parameters (refer to (Wulfmeier et al., 2020) for details), but these were found to be fairly insensitive.
All other parameters were kept ﬁxed, and used for all methods except where highlighted in the following subsections.
All RL experiments were run with 3 seeds to capture variation in each method.
For network architectures, all experiments except for vision used simple 2-layer MLPs for the highand low-level controllers, and for each mid-level mixture component.
An input representation network was used to encode the inputs before passing them to the networks that were learned from scratch: i.e. the high-level for state-based experiments, and both high- and mid-level for vision (re- call that while the state-based experiments can reuse the mid-level components conditioned on object state, the vision-based policy learned them from scratch and KL-regularised to the ofﬂine mid-level skills).
The critic network was a 3-layer MLP, applied to the output of another input representation network (separate to the actor, but with the same architecture) with concatenated action
[Table]
F R EWARDS
Throughout the experiments, we employ different reward functions for different tasks and to study the efﬁcacy of our method in sparse versus dense reward scenarios
[Table]
Reward stages and primitive functions
The reward functions for stacking and pyramid tasks use various reward primitives and staged rewards for completing sub-tasks.
Each of these rewards are within the range of [0 , 1]
These include:
• reach(obj) : a shaped distance reward to bring the TCP to within a certain tolerance of obj .
• grasp() : a binary reward for triggering the gripper’s grasp sensor.
• close_fingers() : a shaped distance reward to bring the ﬁngers inwards.
• lift(obj) : shaped reward for lifting the gripper sufﬁciently high above obj .
• hover(obj1,obj2) : shaped reward for holding obj1 above obj2 .
• stack(obj1,obj2) : a sparse reward, only provided if obj1 is on top of obj2 to within both a horizontal and vertical tolerance.
• above(obj,dist) : shaped reward for being dist above obj , but anywhere horizontally.
• pyramid(obj1,obj2,obj3) : a sparse reward, only provided if obj3 is on top of the point midway between obj1 and obj2 , to within both a horizontal and vertical tolerance.
• place_near(obj1,obj2) : sparse reward provided if obj1 is sufﬁciently near obj2 .
Dense stacking reward The dense stacking reward contains a number of stages, where each stage represents a sub-task and has a maximum reward of 1.
The stages are:
• reach(red) AND grasp() : Reach and grasp the red object.
• lift(red) AND grasp() :
Lift the red object.
• hover(red,blue) :
Hover with the red object above the blue object.
• stack(red,blue) :
Place the red object on top of the blue one.
• stack(red,blue) AND above(red) :
Move the gripper above after a completed stack.
At each timestep, the latest stage to receive non-zero reward is considered to be the current stage, and all previous stages are assigned a reward of 1 .
The reward for this timestep is then obtained by summing rewards for all stages, and scaling by the number of stages, to ensure the highest possible reward on any timestep is 1 .
Sparse staged stacking reward The sparse staged stacking reward is similar to the dense reward variant, but each stage is sparsiﬁed by only providing the reward for the stage once it exceeds a value of 0.95.
This scenario emulates an important real-world problem: that it may be difﬁcult in certain cases to specify carefully shaped meaningful rewards, and it can often be easier to specify (sparsely) whether a condition (such as stacking) has been met.
Sparse stacking reward This fully sparse reward uses the stack(red,blue) function to provide reward only when conditions for stacking red on blue have been met.
Pyramid reward The pyramid-building reward uses a staged sparse reward, where each stage represents a sub-task and has a maximum reward of 1.
If a stage has dense reward, it is sparsiﬁed by only providing the reward once it exceeds a value of 0.95.
The stages are:
• reach(red) AND grasp() : Reach and grasp the red object.
• lift(red) AND grasp() :
Lift the red object.
• hover(red,green) :
Hover with the red object above the green object (with a larger horizontal tolerance, as it does not need to be directly above).
• place_near(red,green) :
Place the red object sufﬁciently close to the green object.
• reach(blue)
AND grasp() : Reach and grasp the blue object.
• lift(blue) AND grasp() :
Lift the blue object.
• hover(blue,green) AND hover(blue,red) :
Hover with the blue object above the central position between red and green objects.
• pyramid(blue,red,green) : Place the blue object on top to make a pyramid.
• pyramid(blue,red,green) AND above(blue) : Move the gripper above after a completed stack.
At each timestep, the latest stage to receive non-zero reward is considered to be the current stage, and all previous stages are assigned a reward of 1 .
The reward for this timestep is then obtained by summing rewards for all stages, and scaling by the number of stages, to ensure the highest possible reward on any timestep is 1 .