P RIMAL W ASSERSTEIN I MITATION L EARNING
Anonymous authors
Paper under double-blind review
A BSTRACT
Imitation Learning (IL) methods seek to match the behavior of an agent with that of an expert.
In the present work, we propose a new IL method based on a conceptually simple algorithm:
Primal Wasserstein Imitation Learning (PWIL), which ties to the primal form of the Wasserstein distance between the expert and the agent state-action distributions.
We present a reward function which is derived ofﬂine, as opposed to recent adversarial IL algorithms that learn a reward function through interactions with the environment, and which requires little ﬁne-tuning.
We show that we can recover expert behavior on a variety of continuous control tasks (beyond locomotion) of the MuJoCo domain in a sample efﬁcient manner in terms of agent interactions and of expert interactions with the environment.
Finally, we show that the behavior of the agent we train matches the behavior of the expert with the Wasserstein distance, rather than the commonly used proxy of performance.
I NTRODUCTION
Reinforcement Learning (RL) has solved a number of difﬁcult tasks whether in games (Tesauro, 1995;
Mnih et al., 2015; Silver et al., 2016) or robotics (Abbeel & Ng, 2004; Andrychowicz et al., 2020).
However, RL relies on the existence of a reward function, that can be either hard to specify or too sparse to be used in practice.
Imitation Learning (IL) is a paradigm that applies to these environments with hard to specify rewards : we seek to solve a task by learning a policy from a ﬁxed number of demonstrations generated by an expert.
IL methods can typically be folded into two paradigms:
Behavioral Cloning, or BC (Pomerleau, 1991; Bagnell et al., 2007; Ross & Bagnell, 2010) and Inverse Reinforcement Learning, or IRL (Russell, 1998; Ng et al., 2000).
In BC, we seek to recover the expert’s behavior by directly learning a policy that matches the expert behavior in some sense.
In IRL, we assume that the demonstrations come from an agent that acts optimally with respect to an unknown reward function that we seek to recover, to subsequently train an agent on it.
Although IRL methods introduce an intermediary problem to solve (i.e. recovering the environment’s reward) they offer the beneﬁt of being less sensitive to distributional shift (Pomerleau, 1991), generalizing to environments with possibly changing dynamics (Piot et al., 2013), or recovering a near-optimal agent from suboptimal demonstrations (Brown et al., 2019; Jacq et al., 2019).
However, IRL methods are usually based on an iterative process alternating between reward estimation and RL, which might result in poor sample-efﬁciency.
Earlier IRL methods (Ng et al., 2000; Abbeel &
Ng, 2004; Ziebart et al., 2008) require multiple calls to a Markov decision process solver (Puterman, 2014), whereas recent adversarial IL approaches (Finn et al., 2016; Ho & Ermon, 2016; Fu et al., 2018) interleave the learning of the reward function with the learning process of the agent.
Adversarial
IL methods are based on an adversarial training paradigm similar to Generative Adversarial Networks (GANs) (Goodfellow et al., 2014), where the learned reward function can be thought of as the confusion of a discriminator that learns to differentiate expert transitions from non expert ones.
These methods are well suited to the IL problem since they implicitly minimize an f -divergence between the state-action distribution of an expert and the state-action distribution of the learning agent (Ghasemipour et al., 2019; Ke et al., 2019).
However the interaction between a generator (the policy) and the discriminator (the reward function) makes it a minmax optimization problem, and therefore comes with practical challenges that might include training instability, sensitivity to hyperparameters and poor sample efﬁciency.
In this work, we use the Wasserstein distance as a measure between the state-action distributions of the expert and of the agent.
Contrary to f -divergences, the Wasserstein distance is a true distance, it is smooth and it is based on the geometry of the metric space it operates on.
The Wasserstein distance has gained popularity in GAN approaches (Arjovsky et al., 2017) through its dual formulation which comes with challenges (see Section 5).
Our approach is novel in the fact that we consider the problem of minimizing the Wasserstein distance through its primal formulation.
Crucially, the primal formulation prevents the minmax optimization problem, and requires little ﬁne tuning.
We introduce a reward function computed ofﬂine based on an upper bound of the primal form of the
Wasserstein distance.
The inferred reward function is non-stationary, like adversarial IL methods, but it is not re-evaluated as the agent interacts with the environment, therefore the reward function we deﬁne is computed ofﬂine .
We present a true distance to compare the behavior of the expert and the behavior of the agent, rather than using the common proxy of performance with respect to the true return of the task we consider (as it is unknown in general).
Our method recovers expert behaviour comparably to existing state-of-the-art methods while being based on signiﬁcantly fewer hyperparameters; it operates even in the extreme low data regime of demonstrations, and is the ﬁrst method that makes Humanoid run with a single (subsampled) demonstration.
B ACKGROUND AND N OTATIONS
Markov decision processes We describe environments as episodic Markov Decision Processes (MDP) with ﬁnite time horizon (Sutton & Barto, 2018) ( S , A , P , r, γ, ρ 0 , T ) , where S is the state space,
A is the action space, P is the transition kernel, r is the reward function, γ is the discount factor, ρ 0 is the initial state distribution and T is the time horizon.
We will denote the dimensionality of S and A as |S| and |A| respectively.
A policy π is a mapping from states to distributions over actions; we denote the space of all policies by Π .
In RL, the goal is to learn a policy π ∗ that maximizes the expected sum of discounted rewards it encounters, that is, the expected return.
Depending on the context, we might use the concept of a cost c rather than a reward r (Puterman, 2014), which essentially moves the goal of the policy from maximizing its return to minimizing its cumlative cost.
State action distributions Suppose a policy π visits the successive states and actions s 1 , a 1 , . . .
, s T , a T during an episode, we deﬁne the empirical state-action distribution ˆ ρ π as: ˆ ρ π = 1 T (cid:80)
Tt =
1 δ s t ,a t , where δ s t ,a t is a Dirac distribution centered on ( s t , a t ) .
Similarly, suppose we have a set of expert demonstrations D
=
{ s e , a e } of size D , then the associated empirical expert state-action distribution ˆ ρ e is deﬁned as: ˆ ρ e = 1 D (cid:80) ( s,a ) ∈D δ s,a .
Wasserstein distance Suppose we have the metric space ( M, d ) where M is a set and d is a metric on M .
Suppose we have µ and ν two distributions on M with ﬁnite moments, the p -th order Wasserstein distance (Villani, 2008) is deﬁned as W pp ( µ, ν )
= inf θ ∈ Θ( µ,ν ) (cid:82) M × M d ( x, y ) p dθ ( x, y ) , where Θ( µ, ν ) is the set of all couplings between µ and ν .
In the remainder, we only consider distributions with ﬁnite support.
A coupling between two distributions of support cardinal T and D is a doubly stochastic matrix of size T × D .
We note Θ the set of all doubly stochastic matrices of size T × D :
[Equation]
The Wasserstein distance between distributions of state-action pairs requires the deﬁnition of a metric d in the space ( S , A ) .
Deﬁning a metric in an MDP is non trivial (Givan et al., 2003; Ferns et al., 2004;
Mahadevan & Maggioni, 2007); we show an example where the metric is learned from demonstrations in Section 4.4.
For now, we assume the existence of a metric d : ( S , A ) × ( S , A ) (cid:55)→ R + .
M ETHOD
We present the theoretical motivation of our approach: the minimization of the Wasserstein distance between the state-action distributions of the agent and the expert.
We introduce a reward based on an upper-bound of the primal form of the Wasserstein distance inferred from a relaxation of the optimal coupling condition, and present the resulting algorithm:
Primal Wasserstein Imitation Learning (PWIL).
3. W ASSERSTEIN DISTANCE MINIMIZATION
Central to our approach is the minimization of the Wasserstein distance between the state-action distribution of the policy we seek to train ˆ ρ π and the state-action distribution of the expert ˆ ρ e .
In other words, we aim at optimizing the following problem:
[Equation]
We can interpret the Wasserstein distance using the earth’s movers analogy (Villani, 2008).
Consider that the state-action pairs of the expert are D holes of mass D − 1 and that the state-action pairs of the policy are piles of dirt of mass T − 1 .
A coupling θ is a transport strategy between the piles of dirt and the holes, where θ [ i, j ] stands for how much of the pile of dirt i should be moved towards the hole j .
The optimal coupling is the one that minimizes the distance that the earth mover travels to put all piles of dirt to holes.
Note that to compute the optimal coupling, we need knowledge of the locations of all piles of dirt.
In the context of RL, this means having access to the full trajectory generated by π .
From now on, we write θ ∗ π as the optimal coupling for the policy π , that we inject in Eq.
[Equation]
i = c ∗ i,π with c ∗ i,π = D (cid:88) j = d (( s πi , a πi
[Equation]
, ( s
[Equation]
In Eq.
(2), we have introduced c ∗ i,π , which we interpret as a cost to minimize using RL.
As c ∗ i,π depends on the optimal coupling θ ∗ π , we can only deﬁne c ∗ i,π at the very end of an episode.
This can be problematic if an agent learns in an online manner or in large time-horizon tasks.
Thus, we introduce an upper bound to the Wasserstein distance that yields a cost we can compute online, based on a suboptimal coupling strategy.
3. G REEDY COUPLING
In this section we introduce the greedy coupling θ gπ ∈ Θ , deﬁned recursively for 1 ≤ i ≤ T as:
[Equation]
with Θ i = (cid:110) θ
[ i, :] ∈ R D + (cid:12)(cid:12)(cid:12) D (cid:88)
[Equation]
(cid:48)
[Equation]
constraint [Equation] Similarly to Equation (1), Equation (3) can be interpreted using the earth mover’s analogy.
Contrary to Equation (1) where we assume knowledge of the positions of the T piles of dirts, we now consider that they appear sequentially, and that the earth’s mover needs to transport the new pile of dirt to holes right when it appears .
To do so, we derive the distances to all holes and move the new pile of dirt to the closest remaining available holes, hence the greedy nature of it.
In Equation (3), the constraint ( a ) means that all the dirt that appears at the i -th timestep needs to be moved, and the constraint ( b ) means that we cannot ﬁll the holes more than their capacity 1 D .
We show the difference between the greedy coupling and the optimal coupling in Figure 1, and provide the pseudo-code to derive it in Algorithm 1.
We present an MDP where we drop the dependency on the action.
The state space is R and the metric associated is the Euclidean distance.
We note the states visited by the policy: s π 1 , s π 2 , s π 3 and the states visited by the expert: s e 1 , s e 2 , s e 3 .
When the policy encounters the state s π 2 , and because we do not know s π 3 yet, the greedy coupling strategy consists in coupling it with s e 2 although the optimal coupling strategy would be to couple it with s e 3 .
Note that the total cost (omitting the constant coupling multiplication factor) with the greedy coupling is 7 whereas the total cost with the optimal coupling is 5 .
This highlights that the optimal coupling needs knowledge about the whole policy’s trajectory to be derived.
We can now deﬁne an upper bound of the Wasserstein distance using the greedy coupling (since by deﬁnition it is suboptimal): [Equation] In Section 4, we empirically validate this bound. We infer a cost from Equation (1) at each timestep i :
[Equation]
Note that the greedy coupling θ gπ [ t, . ] deﬁned in Equation (3) depends on all the previous state-actions visited by the policy π , which makes the cost c gi,π non-stationary, similarly to adversarial IL methods.
We can infer a reward from the cost, r i,π = f ( c gi,π ) where f is a monotonously decreasing function.
This reward function is an episodic history dependent reward function r ( s 0 , a 0 , . . .
, s t , a t ) where r is uniquely deﬁned from expert demonstrations (hence is said to be derived ofﬂine ).
Crucially, we have deﬁned a reward function that we seek to maximize, without introducing an inner minimization problem (which is the case with adversarial IL approaches).
We can now derive an algorithm building on this reward function (Algorithm 1).
The algorithm presented is written using pseudo-code for a generic agent A which implements a policy π A , it observes tuples ( s, a, r, s (cid:48) ) and possibly updates its components.
The runtime of the algorithm for a single reward step computation has complexity O (( |S| + |A| )
D + D 2 T ) (see appendix for details), and therefore has complexity O (( |S| + |A| ) DT + D 2 ) for computing rewards across the entire episode.
Note that in the case where T =
D , computing the greedy coupling is simply a lookup of the expert state-action pair that minimizes the distance with the agent state-action pair, followed by a pop-out of this minimizing expert state-action pair from the set of expert demonstrations.
Algorithm 1 introduces an agent with the capability to observe and update itself, which is directly inspired from ACME’s formalism of agents (Hoffman et al., 2020), and is general enough to characterize a wide range of agents.
We give an example rundown of the algorithm in Section D.
Input: Expert demonstrations D = { s ej , a ej } j ∈ [1: D ] , Agent A , number of episodes N for k = 1 to N do
Copy expert demonstrations with weight: D (cid:48) :
= { s ej , a ej , w ej } j ∈ [1: D ] , with w ej = 1 D
Reset environment, initial state s for i = 1 to T do
Take action a :=
π A ( s ) , observe next state s (cid:48)
Initialize weight w π := 1 T , cost c :=while w π > 0 do
Compute s e , a e , w e := arg min ( s e ,a e ,w e ) ∈D (cid:48)
d (( s, a ) , ( s e , a e )) if w π ≥ w e then c :=
c + w e d (( s, a ) , ( s e , a e ))
w π := w π − w e
D (cid:48) .
pop ( s e , a e , w e ) else c := c + w π d (( s, a ) , ( s e , a e ))
w e := w e − w π w π :=r :=
f
( c )
A observes ( s , a , r , s (cid:48) ), updates itself
E XPERIMENTS
In this section, we present the implementation of PWIL and perform an empirical evaluation, based on the ACME framework (Hoffman et al., 2020).
We test PWIL on the standard imitation learning
MuJoCo locomotion tasks and compare it to the state of the art GAIL-like algorithm DAC (Kostrikov et al., 2019) and against the common BC baseline.
As DAC is based on TD3 which is a variant of DDPG, we use a DDPG-based agent for fair comparison.
We also provide a proof-of-concept experiment on a door opening task where the demonstrations do not include actions and are pixelbased and therefore the metric of the MDP has to be learned.
In this setup, we use SAC as the direct
RL method.
We answer the following questions: 1) Does PWIL recover expert behavior?
2) How sample efﬁcient is PWIL?
3) Does PWIL actually minimize the Wasserstein distance between the distributions of the agent and the expert? 4)
Does PWIL extend to visual based observations where the deﬁnition of an MDP metric is not straightforward?
We also show the dependence of PWIL on multiple of its components through an ablation study.
The complete description of the experiments is in the appendix.
We attached the code and expert demonstrations for locomotion experiments, as well as videos of the agents in the supplementary material.
4. I MPLEMENTATION
We test PWIL following the same evaluation protocol as GAIL (Ho & Ermon, 2016) and DAC (Kostrikov et al., 2019), on six environments from the OpenAI Gym MuJoCo suite (Todorov et al., 2012; Brockman et al., 2016).
For each environment, multiple demonstrations are gathered using a
DDPG agent with a distributional critic (Lillicrap et al., 2016; Barth-Maron et al., 2018) trained on the actual reward of these environments (which was chosen as it is a base agent in the ACME framework (Hoffman et al., 2020)).
We subsample demonstrations by a factor of 20: we select one out of every 20 transitions with a random offset at the beginning of the episode.
The point of subsampling is to simulate a low data regime, so that a pure behavioral cloning approach suffers the behavioral drift and hence does not perform to the level of the expert.
We run experiments with multiple number of demonstrations: { 1 , 4 , 11 } (consistently with the evaluation protocol of DAC).
Central to our method is a metric between state-action pairs.
We use the standardized Euclidean distance which is the L2 distance, weighted along each dimension by the inverse standard deviation of the expert demonstrations.
From the cost c i deﬁned in Equation (5), we deﬁne the following reward:
[Equation]
For all environments, we use α = 5 and β = 5 .
The scaling factor
T √ |S| + |A| acts as a normalizer on the dimensionality of the state and action spaces and on the time horizon of the task.
We pick f : x (cid:55)→ exp( − x ) as the monotonously decreasing function to get a reward from a cost because it is smooth and has a bounded range [0 , 1] .
We test our method against a state-of-the-art imitation learning algorithm:
Discriminator Actor
Critic (DAC) (Kostrikov et al., 2019) and BC (Pomerleau, 1991).
DAC is based on GAIL: it discriminates between expert and non-expert early termination states and it uses an off-policy algorithm TD3 (Fujimoto et al., 2018) which is a variant of DDPG instead of the on-policy algorithm
TRPO (Schulman et al., 2015).
We used the open-source code provided by the authors.
The Humanoid environment is not studied in the original DAC paper.
The hyperparameters the authors provided having poor performance, we led an exhaustive search detailed in Section A.2, and present results for the best hyperparameters found.
For our method, we use a DDPG agent (Lillicrap et al., 2016) with a distributional critic (Bellemare et al., 2017; Barth-Maron et al., 2018)
(see details in the appendix).
We initialize the replay buffer by ﬁlling it with expert state-action pairs with maximum reward (i.e. α ).
We train PWIL and DAC in the limit of 1M environment interactions (2.5M for Humanoid) on 10 seeds.
Every 10k environment steps, we perform 10-episode rollouts per seed of the policy without exploration noise and report performance with respect to the environment’s original reward in Figure 2.
4. R ESULTS
In Figure 2, PWIL shows improvement on ﬁnal performance for Hopper, Ant, HalfCheetah and
Humanoid over DAC, similar performance for Walker2d, and is worse on Reacher.
On Humanoid, although we ran an exhaustive hyperparameter search (see Section A.2) DAC has poor performance, thus exemplifying the brittleness of GAIL-like approaches.
On the contrary, PWIL has near-optimal performance, even with a single demonstration.
In terms of sample efﬁciency, DAC outperforms PWIL on HalfCheetah, Ant and Reacher and has similar performance for Hopper and Walker2d.
Note that ablated versions of PWIL are more sampleefﬁcient than DAC on HalfCheetah and Ant (Section C).
This seems rather contradictory with the claim that GAIL-like methods have poor sample efﬁciency.
However the reward function deﬁned in
DAC requires careful tuning (e.g. architecture, optimizer, regularizers, learning rate schedule) which demands experimental cycles and therefore comes with a large number of environment interactions.
Remarkably, PWIL is the ﬁrst method able to consistently learn policies on Humanoid with an average score over 7000 even with a single demonstration, which means that the agent can actually run , (other works consider Humanoid is "solved" for a score of 5000 wich corresponds to standing ).
Wasserstein distance.
In Figure 3, we show the Wasserstein distance to expert demonstrations throughout the learning procedure for PWIL and DAC.
The Wasserstein distance is evaluated at the end of an episode using a transportation simplex (Bonneel et al., 2011); we used the implementation from
Flamary & Courty (2017).
For both methods, we notice that the distance decreases while learning.
PWIL leads to a smaller Wasserstein distance than DAC on all environments but HalfCheetah where it is similar and Reacher where it is larger.
This should not come as a surprise since PWIL’s objective is to minimize the Wasserstein distance.
PWIL deﬁnes a reward from an upper bound to the Wasserstein distance between the state-action distributions of the expert and the agent, that we include as well in Figure 3.
Notice that our upper bound is “empirically tight”, which validates the choice of the greedy coupling as an approximation to the optimal coupling.
We emphasize that this distance is useful in real settings of IL, regardless of the method used, where we cannot have access to the actual reward of the task.
4. A BLATION S TUDY
We run an ablation study on the components of PWIL to highlight the inﬂuence of its components.
We provide comprehensive results in the appendix and summarize ﬁndings here.
Pre-ﬁlling the replay buffer with expert demonstrations is necessary on Reacher and Walker to get near-expert performance, and otherwise slightly helps.
PWIL is sensitive to the quality of the metric as we have that the Euclidean distance (instead of the standardized one) leads to poor performance.
PWIL is somewhat close to expert support estimation methods (Brantley et al., 2020; Wang et al., 2019), with the difference being that in the case of PWIL the expert support “shrinks” as the demonstrations used to compute rewards throughout the episode are removed; we therefore implemented a version of
PWIL where the demonstrations are not removed, and found a large drop in performance.
Finally, if the distance in the MDP is based on the state rather than the state and action, which is the Learning from Observation (LfO) setting (Torabi et al.
; Edwards et al.
, PWIL is still able to recover near-expert performance on all tasks but Walker2d.
4. D OOR O PENING T ASK : R EWARD F ROM P IXEL -B ASED O BSERVATIONS
In this section, we show that PWIL extends to visual-based setups, where the MDP metric has to be learned.
We use the door opening task from Rajeswaran et al.
(2018), with human demonstrations generated with Haptix (Kumar & Todorov, 2015).
The goal of the task is for the controlled hand to open the door (Figure 4) whose location changes at each episode.
We add an early termination constraint when the door is opened (hence suppressing the incentive for survival).
We assume that we can only access the high-dimensional visual rendering of the demonstrations rather than the internal state (and hence have no access to actions, that is LfO setting).
The PWIL reward is therefore deﬁned using a distance between the visual rendering of the current state and the visual rendering of the demonstrations.
This distance is learned ofﬂine through selfsupervised learning: we construct an embedding of the frames using Temporal Cycle-Consistency
Learning (TCC) (Dwibedi et al., 2019);
TCC builds an embedding by aligning frames of videos of a task coming from multiple examples (in this case the demonstrations).
The distance follows as the L distance between embeddings.
The distance is learned on the 25 human demonstrations provided by Rajeswaran et al.
(2018) which are then re-used to deﬁne the PWIL reward.
From the cost c i deﬁned in Equation (5), we deﬁne the following reward: r i = α exp( − βTc i ) , with α = 5 , β = 1 .
We used SAC (Haarnoja et al., 2018a) as the forward RL algorithm, which was more robust than
DDPG on the task.
We train the agent on 1.5M environment steps and show that we indeed recover expert behaviour and consistently solve the task in Figure 5.
R ELATED W ORK
Adversarial IL Similarly to our method, adversarial IL methods aim at matching the state-action distribution of the agent with the distribution of the expert, using different measures of similarity.
For instance, GAIL (Ho & Ermon, 2016) considers the Shannon-Jensen divergence while AIRL (Fu et al., 2018) considers the Kullback-Leibler divergence.
In the context of GANs, Arjovsky et al.
(2017) show that replacing the f -divergence by the Wasserstein distance through the Kantorovich-Rubinstein duality (Villani, 2008) leads to better training stability, which a number of methods in IL have leveraged
(Li et al., 2017; Lacotte et al., 2019; Kostrikov et al., 2019; Xiao et al., 2019; Liu et al., 2020).
However, the Kantorovich-Rubinstein duality only holds for the W 1 distance (Peyré et al., 2019), its implementation comes with a number of practical approximations ( e.g. , weight clipping to ensure Lipchitz continuity).
Although these methods are based on the Wasserstein distance through its dual formulation, they drastically differ from ours as they rely on a minmax optimization problem.
DAC (Kostrikov et al., 2019) demonstrates that adversarial IL approaches, while based on GAIL, can be sample efﬁcient.
However, they rely on a carefully tuned discriminator (e.g. network architecture, regularization strategy, scheduled learning rates) which requires to interact with the environment.
In contrast, the reward function we present relies on only two hyperparameters.
Expert support estimation Another line of research in IL consists in estimating the state-action support of the expert and deﬁne a reward that encourages the agent to stay on the support of the expert (Piot et al., 2014; Schroecker & Isbell, 2017; Wang et al., 2019; Brantley et al., 2020;
Reddy et al., 2020).
Note that the agent might stay on the support of the expert without recovering its state-action distribution.
Soft Q Imitation Learning (Reddy et al., 2020) assigns a reward of 1 to all expert transitions and 0 to all transitions the expert encounters; the method learns to recover expert behavior by balancing out the expert transitions with the agent transitions in the replay buffer of a value-based agent.
Random Expert Distillation (Wang et al., 2019) estimates the support by using a neural network trained on expert transitions whose target is a ﬁxed random neural network.
Disagreement Regularized Imitation Learning (Brantley et al., 2020) estimates the expert support through the variance of an ensemble of BC agents, and use a reward based on the distance to the expert support and the KL divergence with the BC policies.
PWIL differs from these methods since it is based on the distance to the support of the expert, with a support that shrinks through “pop-outs” to enforce the agent to visit the whole support.
We showed in the ablation study that “pop-outs” are sine qua non for recovering expert behaviour (see PWIL-support ).
Trajectory-Based IL Similarly to the door opening experiment, Aytar et al.
(2018) learns an embedding ofﬂine and reinforces a reward based on the distance in the embedding space to a single demonstration.
However, it is well suited for deterministic environments since they use a single trajectory that the agent aims at reproducing while the door experiment shows that PWIL is able to generalize as the door and handle locations are picked at random.
Peng et al.
(2018) reinforces a temporal reward function (the reward at time t is based on the distance of the state of the agent to the state of the expert at time t ).
Contrary to PWIL, the imitation reward function is added to a task-dependent reward function; the distance to expert demonstrations is deﬁned along handpicked dimensions of the observation space; the temporal constraint makes it hard to generalize to environment with stochastic initial states.
MMD-IL Generative Moment Matching Imitation Learning (Kim & Park, 2018) assumes a metric on the MDP and aims at minimizing the Maximum Mean Discrepancy (MMD) between the agent and the expert.
However, the MMD (like the Wasserstein distance) requires complete rollouts of the agent, and does not present a natural relaxation like the greedy coupling.
MMD is based on an on-policy agent (well adapted to rollouts) which makes it signiﬁcantly less sample-efﬁcient than PWIL.
We were not able to implement a version of MMD based on an off-policy agent.
C ONCLUSION
In this work, we present Imitation Learning as a distribution matching problem and introduce a reward function which is based on an upper bound of the Wasserstein distance between the state-action distributions of the agent and the expert.
A number of IL methods are developed on synthetic tasks, where the evaluation of the IL method can be done with the actual return of the task.
We emphasize that in our work, we present a direct measure of similarity between the expert and the agent, that we can thus use in real IL settings, that is in settings where the reward of the task cannot be speciﬁed.
The reward function we introduce is learned ofﬂine, in the sense that it does not need to be updated with interactions with the environment.
It requires little tuning (2 hyperparameters) and it can recover near expert performance with as little as 1 demonstration on all considered environments, even the challenging Humanoid.
Finally our method extends to the harder visual-based setting, based on a metric learned ofﬂine from expert demonstrations using self-supervised learning.
A L OCOMOTION E XPERIMENTS A. PWIL I MPLEMENTATION
The agent we use is DDPG (Lillicrap et al., 2016) with a distributional critic (Barth-Maron et al., 2018).
We use the default architecture from the ACME framework (Hoffman et al., 2020).
The actor architecture is a 4-layer neural network: the ﬁrst layer has size 256 with tanh activation and layer normalization (Ba et al., 2016), the second layer and third layer have size 256 with elu activation (Clevert et al., 2016), the last layer is of size the dimension of the action space, with a tanh activation scaled to the action range of the environment.
To enable sufﬁcient exploration with use a Gaussian noise layer on top of the last layer with standard deviation σ = 0 . 2 , that we clip to the action range of the environment.
We evaluate the agent without exploration noise.
For the critic network we use a 4-layer neural network: the ﬁrst layer has size 512 with tanh activation and layer normalization, the second layer is of size 512 with elu activation, the third layer is of size 256 with elu activation, the last layer is of dimension 201 with a softmax activation.
The 201 neurons stand for the weights of the distribution supported within equal distance in the range [ − 150 , 150] , as a categorical distribution (Bellemare et al., 2017).
We use the Adam optimizer (Kingma & Ba, 2015) with λ a = 5 × 10 − 5 for the actor and λ r = 7 × 10 −for the critic.
We use a batch size of 256.
We clip both gradients from the critic and the actor to limit their L2 norm to 40 .
We use a replay buffer of size 10 6 , a discount factor θ = 0 .
99 and n step returns with n = 5 .
We preﬁll the replay buffer with 50000 state-action pairs from the set of demonstrations (which means that we put multiple times the same expert transitions in the buffer).
We perform updates on the actor and the critic every k = 4 interactions with the environment.
The hyperparameters search is detailed in Table 1.
Parameters
Values
[Table]
For the reward function, we did run a hyperparameter search on α and β with the following values for α and β in { 1 , 5 , 10 } .
A. DAC I MPLEMENTATION
We used the open-source implementation of DAC provided by Kostrikov et al.
For Humanoid (which was not reported in the paper), we did run a large hyperparameter search described in Table 2.
Out of the 729 experiments, 7 led to an average performance above 1000 at the 2.5M training environment steps mark.
[Table]
A. BC I MPLEMENTATION
We used a 3-layer neural network, the ﬁrst layer has size 128 with relu activation, the second layer has size 64 and the last layer has size of the action space with a tanh activation scaled to the action range of the environment.
We found out that normalizing the observations with the average and standard deviation of the expert demonstrations’ observations helped performance.
We trained the network using the mean squared error as a loss, with an Adam optimizer.
We ran an hyperpameter search on the learning rate in { 10 − 5 , 10 − 4 , 10 − 3 } and on the batch size { 128 , 256 } .
A. PWIL L EARNING C URVES
We present the learning curves of PWIL, in terms of the reward deﬁned in Equation 6 as well as the original reward of the task
B D OOR O PENING E XPERIMENTS
In this section we present the details of the experiment presented in Section 4.4.
We are working on open-sourcing the code of these experiments.
B. E NVIRONMENT
The default door opening environment has a ﬁxed horizon of 200 timesteps.
We add an early termination condition to the environment when the door is opened to demonstrate that PWIL extends to tasks where there is no incentive for survival.
Note that similarly to AIRL (Fu et al., 2018), early termination states are considered to be absorbing.
Therefore if the expert reaches an early termination state early, its state distribution as a large weight on these states, which leads the PWIL agent to similarly reach the early termination state.
25 demonstrations were collected from humans using a virtual reality system (Kumar & Todorov (2015)).
B. E MBEDDING
As we assume that we only have access to the visual rendering of the demonstrations (with resolution 84 × 84 ), we build a lower dimensional latent space.
We use a self-supervised learning method: TCC, to learn the latent space.
We used the classiﬁcation version of the algorithm detailed in Dwibedi et al.
(2019) (Section 3.2).
The encoding network is the following: a convolutional layer with 128 ﬁlters of size 8 and stride 4, a relu activation, a convolutional layer with 64 ﬁlters of size 4 and stride 2, a relu activation, a convolutional layer with 64 ﬁlters of size 3 and stride 1, a relu activation, a linear layer of size 128, a relu activation and an output layer of size 32.
We separated the demonstrations into a train set ofdemonstrations and a validation set of 5 demonstrations.
Similarly to Dwibedi et al.
(2019), we select the encoding network by taking the one that maximizes the alignment according to Kendall’s tau score on the validation set.
We ran an hyperparameter search over the batch size { 1 ,
32 } , the subsampling ratio and the
learning
rate {
− 2 ,
− 3 ,
−
} (using the Adam optimizer).
The best performing encoder had an average Kendall’s tau score of 0.98 on the training set and 0.91 on the validation set.
B. A GENT
In this setup, we found that SAC leads to better results than
D4PG.
We detail the implementation of SAC below.
The actor is a 3-layer network that outputs the parameters of a normal distribution with diagonal covariance matrix.
We enforce the terms of the covariance matrix to be greater than 10 − 3 .
The ﬁrst layer has size 256 with relu activation, the second layer has size 256 with relu activation and the last layer has size 48 (the action space has size 24).
The critic is a 3-layer network.
We pass the concatenation of the state and the action of the environment as an input.
There are two hidden layers of size 256 with relu activation.
We do use a twin critic.
We use an adaptive temperature α as described by Haarnoja et al.
(2018b
For the three losses we use the Adam optimizer, and we use Polyak averaging for the critic networks with a rate τ .
We ran an hyperparameter search over the learning rates λ a , λ c , λ α in { 10 − 4 , 3 × 10 − 4 } , over τ { 0 . 01 , 0 . 005 } , over the batch size { 64 , 128 , 256 } and over the number of interactions with the environment between each actor, critic and temperature update { 1 , 4 , 8 } .
C A BLATION STUDY
In this section, we present the evaluation performance of PWIL in the presence of ablations and report results in Figure 10.
We keep the hyperparameters of the original PWIL agent ﬁxed.
PWIL-state
In this version of PWIL, we do not assume that we have access to the actions taken by the expert.
Therefore, we try to match the state distribution of the agent with the state distribution of the expert (instead of the state-action distribution).
The setup is referred to as Learning from
Observation (LfO) (Torabi et al., 2018; Edwards et al., 2019).
The reward is deﬁned similarly to PWIL, using a state distance rather than a state-action distance.
Note that in this version, we cannot pre-ﬁll the replay buffer with expert state-action pairs since we do not have access to actions.
Remarkably, PWIL-state recovers non-trivial behaviors on all environments.
PWIL-L
In this version of PWIL, we use the Euclidean distance between state-action pairs, rather than the standardized Euclidean distance.
In other words, we do not weight the state-action distance by the inverse standard deviation of the expert demonstrations along each dimension.
There is a signiﬁcant drop in performance for all environments but Hopper-v2.
This shows that the performance of PWIL is sensitive to the quality of the MDP metric.
PWIL-noﬁll In this version, we do not preﬁll the replay buffer with expert transitions.
This leads to a drop in performance which is signiﬁcant for Walker and Ant.
This should not come as a surprise since a number of IL methods leverage the idea of expert transitions in the replay buffer (Reddy et al., 2020; Hester et al., 2018).
PWIL-support In this version of PWIL, we deﬁne the reward as a function of the following cost:
[Equation]
We can interpret this cost in the context of Section 3 as the problem of moving piles of dirt of mass
T into holes of inﬁnite capacity.
It is thus reminiscent of methods that consider IL as a support estimation problem (Wang et al., 2019; Brantley et al., 2020).
This leads to a signiﬁcant drop in performance for Ant, Walker and HalfCheetah. [Equation]
We present an example rundown of PWIL in Figure 12.
E A LGORITHM R UNTIME
We detail the runtime of PWIL here.
A single step reward computation consists in computing the distance from the current observation (a vector with dimension |S| + |A| with D vectors (the expert observations), which has complexity
O (( |S| + |A| ) D ) .
The next step is to get the minimum of these distances (complexity O ( D ) ), for (cid:100) DT (cid:101) times (the number of times the algorithm executes the while loop).
Therefore the complexity of a single step reward computation is O (( |S| + |A| )
D + D 2 T ) and the complexity of the reward computation of an episode is O (( |S| + |A| )
DT + D 2 ) .