{'fraction_non_alphanumeric': 0.04423741362290227, 'fraction_numerical': 0.015023445212240869, 'mean_word_length': 4.8063765000895575, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Deterministic and Discriminative Imitation (D2-Imitation): Revisiting Adversarial Imitation for Sample Efficiency

Sample efficiency is crucial for imitation learning methods to be applicable in real-world applications. Many studies improve sample efficiency by extending adversarial imitation to be off-policy regardless of the fact that these off-policy extensions could either change the original objective or involve complicated optimization. We revisit the foundation of adversarial imitation and propose an off-policy sample efficient approach that requires no adversarial training or min-max optimization. Our formulation capitalizes on two key insights: (1) the similarity between the Bellman equation and the stationary state-action distribution equation allows us to derive a novel temporal difference (TD) learning approach; and (2) the use of a deterministic policy simplifies the TD learning. Combined, these insights yield a practical algorithm, Deterministic and Discriminative Imitation (D2-Imitation), which operates by first partitioning samples into two replay buffers and then learning a deterministic policy via off-policy reinforcement learning. Our empirical results show that D2-Imitation is effective in achieving good sample efficiency, outperforming several off-policy extension approaches of adversarial imitation on many control tasks.


Introduction
We consider a specific imitation learning task: given a limited number of expert demonstrations, learn an optimal policy in a simulator without any access to the expert policy or reinforcement signals of any kind. One of the important approaches for this problem setting, a.k.a Apprenticeship Learning (Abbeel and Ng 2004), is adversarial imitation, which learns a policy by minimizing the divergence between the stationary state-action distribution induced by the policy and the expert distribution given in the demonstrations (Ho and Ermon 2016;Kostrikov et al. 2018;Ke et al. 2019;Ghasemipour, Zemel, and Gu 2020). As the two distributions are given in the form of empirical samples, adversarial imitation has to roll out the policy to collect onpolicy samples and then estimates the empirical divergence by training a discriminator (Ho and Ermon 2016). Those onpolicy samples are then discarded immediately after each policy update. The resulting sample inefficiency is a crucial limitation, ruling out many real-world applications, where collecting interactions is often slow (e.g., physical robotics) or expensive (e.g., autonomous driving). Some methods improve sample efficiency by relaxing the on-policy requirement in adversarial imitation, e.g., using off-policy samples to train the discriminator and policy (Kostrikov et al. 2018;Sasaki, Yohira, and Kawaguchi 2018). Doing so, however, changes the original divergence minimization objective, hence providing no guarantee that the learned policy recovers the expert distribution (Kostrikov, Nachum, and Tompson 2019;Sun et al. 2021). Furthermore, the non-stationary rewards generated by the discriminator make actor-critic algorithms converge slowly (or even diverge) (Sutton and Barto 2018) and could demand significantly more samples to learn a good policy (Schulman et al. 2015;Fujimoto, van Hoof, and Meger 2018). Other methods translate the on-policy distribution matching problem into an off-policy optimization, which also circumvents the need to learn rewards (Kostrikov, Nachum, and Tompson 2019;Sun et al. 2021). This type of approach involves a non-convex min-max optimization procedure that requires well-tuned regularization (Gulrajani et al. 2017), limiting its practical application.
In this paper, we revisit the foundation of adversarial imitation and propose an off-policy learning approach, Deterministic and Discriminative Imitation (D2-Imitation), that involves no adversarial training or non-convex min-max optimization. D2-Imitation capitalizes on two key insights: (1) the similarity between the Bellman equation and the stationarity equation of the state-action distribution from the formulation of adversarial imitation, and (2) the benefit of using a deterministic policy in the stationarity equation. In particular, instead of defining the divergence for distribution matching as in Ho and Ermon (2016); Ghasemipour, Zemel, and Gu (2020), we derive a temporal difference (TD) learning approach from the stationarity equation, which directly learns a proxy for the expert state-action distribution. Furthermore, we show that the use of a deterministic policy simplifies TD learning and yields a practical imitation learning algorithm, which operates by first partitioning samples into two replay buffers via a discriminator, and then learning a deterministic policy via off-policy RL, as presented in Figure 1. More specifically, D2-Imitation first trains a discriminator D φ with state-action pairs from demonstrations (i.e., positive samples) and randomly generated samples. Whenever a sample is collected by rolling out the policy in simulation, the discriminator determines which buffer, B + or B 0 , the sample should be put in. D2-Imitation then uniformly samples from the two replay buffers, assigns positive rewards to the samples from B + and zero to those from B 0 , and uses those samples to update the proxy estimate of state-action distribution via an off-policy RL algorithm. We show that the notion of partitioning samples into two groups and assigning constant rewards follows theoretically from the use of a deterministic policy. Our empirical results show that D2-Imitation is effective in achieving good sample efficiency, outperforming many adversarial imitation approaches on different benchmark tasks with demonstrations from either deterministic or stochastic policies.

Background
Preliminaries We consider an infinite-horizon Markov decision process (MDP) with a finite state space S, a finite action space A, a transition kernel p : S × A × S → (0, 1], a reward function r : S ×A → R, a discount factor γ ∈ [0, 1), and an initial state distribution p 0 from which s 0 is sampled. An agent then interacts with its environment in discrete time steps as follows: at each time step t the agent observes environment state s t ∈ S, takes an action a t ∈ A and transitions to a successor state s t+1 ∈ S, also denoted as s if the subscript is omitted. The agent's behavior is defined by a policy π, which maps states to a probability distribution over the action: π : S → P(A). A policy is deterministic if the probability distribution degenerates to a probability mass point. We use µ to denote a deterministic policy and µ(s) to denote the action for s. The return from a state is defined as the sum of discounted future The return depends on the actions chosen, and therefore on policy π. A policy is optimal if it maximizes the expected return from the start distribution J(π) = E s0∼p0,πt [R 0 ]. In imitation learning, the agent needs to learn an optimal policy from expert samples (s E , a E ) that are generated by an optimal policy π E , assuming the reward function r is unknown and no reinforcement signals of any kind are available.
Deterministic policy gradients For a parametrized policy π θ , its parameters θ can be updated in the direction of the performance gradient ∇ θ J(π θ ). When the policy is deterministic, the parameters can be updated through the de-terministic policy gradient (Silver et al. 2014), where d π is the state distribution induced by π (the formal definition is given in the next section), and Q π (s, a), also called the action value function, is the expected return after taking a t in state s t and thereafter following π: Q π (s t , a t ) = E r i≥t ,s i≥t ∼p,a i≥t ∼π R t |s t , a t , To learn Q π (s, a), one can update the critic recursively based on the Bellman equation (Sutton and Barto 2018): For a large state space, the value function can be estimated with a differentiable neural network Q φ (s, a), with parameters φ. To stabilize the training, in deep Q-learning (Mnih et al. 2015), the network is updated by temporal difference learning with a target network Q φ (s, a) to maintain a fixed objective y over multiple updates: y = r + γQ φ (s , a ), a ∼ π θ (s ), where the actions are selected from a target actor network π θ .

Analysis of Stationary Distribution
We first revisit adversarial imitation and analyze the pivotal idea that underpins this family of approaches: the stationarity equation for state-action distributions. We show the similarity between the stationarity equation and the Bellman equation, and propose a temporal difference learning approach to learn a proxy for the state-action distribution. Finally, we consider a practical algorithm that learns a deterministic policy in an off-policy manner.

Distribution Matching in Adversarial Imitation
Adversarial imitation capitalizes on the idea that the stationary distribution induced by the learned policy should match the empirical state-action distribution presented in the demonstrations (Ho and Ermon 2016). To characterize such idea, we first describe the duality between a policy and its stationary state-action distribution. For a policy π ∈ Π, define its stationary state-action distribution as d(s, a) = (1 − γ) ∞ t=0 γ t d t (s, a), where d t (s, a) = P s t = s, a t = a|s 0 ∼ p 0 , a i ∼ π(·|s i ), s i+1 ∼ p(·|s i , a i ), ∀i < t . A basic result from Puterman (2014) is that the set of valid stateaction distributions Ω {d π : π ∈ Π} can be characterized by a feasible set of affine constraints, if p 0 (s) is the starting state distribution (p 0 (s) > 0 ∀s ∈ S), then  (3), then d is the state-action distribution for π d(s, a)/ a d(s, a), and π is the only policy whose state-action distribution is d.
This proposition also holds for deterministic policies. In particular, a solution d is a basic feasible solution (BFS) of affine constraints if it cannot be expressed as a nontrivial convex combination of any other feasible solutions. If d(s, a) is a BFS of Equation (3), then π is deterministic and vice versa. Thus, for a BFS d(s, a) and its corresponding deterministic policy µ, we always have d(s, a) = 0 if a = µ(s) and d(s, µ(s)) > 0 ( Puterman 2014).
Proposition 1 forms the foundation of distribution matching approaches for adversarial imitation. Specifically, since the stationary state-action distribution uniquely describes a policy, one can learn a policy π by minimizing the difference between two distributions: the state-action distribution d π (s, a) induced by the policy π and the state-action distribution d E (s, a) in the demonstrations (Ho and Ermon 2016;Kostrikov et al. 2018;Ke et al. 2019;Ghasemipour, Zemel, and Gu 2020). In adversarial imitation, the distribution difference is estimated via a discriminator, which requires rolling out the policy (i.e., generator) to simulate an MDP process and to collect on-policy samples from d π (s, a) whenever the policy is updated in training (Ho and Ermon 2016). Those on-policy samples are discarded immediately after each iteration (Kostrikov et al. 2018;Kostrikov, Nachum, and Tompson 2019). We take a different perspective by formulating a novel learning method from Equation (3), without resorting to any divergence minimization or repeatedly requiring on-policy samples.

Distribution Matching by TD Learning
At first glance, the stationarity equation (3) resembles the Bellman equation for action-value functions. Specifically, multiplying by π(a |s ) on both sides of (3), we have d(s , a ) = (1 − γ)p 0 (s )π(a |s )+ γ s,a π(a |s )p(s |s, a)d(s, a), (4) which holds for d ≥ 0, ∀(s , a ) ∈ S × A. With this new formulation, d(s, a) can be reinterpreted as the action-value function and (1 − γ)p 0 (s )π(a |s ) as the expected reward over the state s (denote r(s, a) = (1 − γ)p 0 (s)π(a|s)). The Bellman equation (2) bootstraps the estimate of the current action value Q(s, a) on the next ones (s , a ), i.e., leveraging successor samples. By contrast, the stationary equation (4) operates backwards by bootstrapping the current value d(s , a ) on the previous ones (s, a), i.e., leveraging predecessor samples. In practice, it is difficult to directly obtain predecessor samples in model-free learning (Liu et al. 2018). We thus consider an alternative equation as follows, which modifies the original stationarity equation by considering successor samples, rather than predecessor ones. We used(s, a) to note thatd(s, a) defined by this equation is not strictly a stationary state-action distribution for any π.
The first part of this assumption can be easily fulfilled in the real world as long as the problem to be considered has a recurring structure (Levin and Peres 2017). The second part is to ensure thatd(s, a) is well-defined (Yu 2015). We then have the following, Theorem 1. For any strictly positive function p 0 (s), the affine constraints defined in Equations (4) and (5) have the same set of BFSs.
Proof. Denote BFS as d B (s, a) and its corresponding policy as µ. Since d B is a BFS, we have d B (s, a) = 0 if a = µ(s) following from Proposition 1. We only need to show that d B (s, a) remains feasible for any strictly positive p 0 (s).
The affine constraints given in Equations (4) and (5) can be represented in the matrix form d also exists given that (I − γP π ) −1 exists. Thus for both affine constraints, the BFSs are determined as follows: For strictly positive function p 0 (s), we have p 0 > 0. Also, since γ ∈ [0, 1) and the Markov chain induced by π is ergodic (also iperiodic), we have ∀s, is feasible for both affine constraints. Therefore, the set of BFSs for these two affine constraints are the same.
Furthermore, as Equation (5) relies on the successor samples, we can thus construct the following temporal difference (TD) update rule to learnd(s, a), where r(s t , a t ) = (1 − γ)p 0 (s t )π(a t |s t ) and {α t } is a deterministic positive non-increasing sequence satisfying the Robbins-Monro condition (Robbins and Monro 1951), i.e., in Equation (6). However, in Apprenticeship Learning, we have access only to state-action samples, i.e., {(s, a) : a ∼ π E (·|s)}. Thus, the reward r(s, a) = (1 − γ)p 0 (s)µ E (a|s) in Equation (6) is generally unknown. In the following, we show that the reward configuration can be simplified for a deterministic policy, which yields a practical algorithm.
For a deterministic policy µ E , the reward r(s, a) in Equation (6) can be further simplified. Specifically, we have According to Theorem 1, the set of BFSs, corresponding to the deterministic policy, does not rely on p 0 (s) as long as it is strictly positive for all states. We can thus redefine r(s, a) as: r d (s, a) = 1 for a = µ E (s), and r d (s, a) = 0 for a = µ E (s). Namely, we can partition all state-action pairs into two groups (corresponding to two replay buffers) based on µ E (s): a positive buffer B + , which contains all (s, a) such that a = µ E (s), and a nil buffer B 0 , which contains all (s, a) such that a = µ E (s). As we have no access to the expert policy µ E and no further queries can be made, we have to learn a discriminator that can tell whether a = µ E (s) or a = µ E (s) for a given (s, a). Since the demonstrations are given as a finite set of samples {(s E , a E ) : a E ∼ π(·|s E )}, we can train such a discriminator as follows: for each s E ∈ {(s E , a E ) : a E ∼ π E (·|s)}, generate some random actions a rnd to form samples (s E , a rnd ), assign negative labels to the random samples and positive labels to the expert samples, and train a discriminator via supervised learning with those labeled samples. Furthermore, following from Theorem 1, we can learn BFSs for µ E via TD learning by updatingd(s, a) with samples that are uniformly sampled from two replay buffers. For continuous action spaces, an expert policy µ E parametrized with θ µ could be directly learned via deep deterministic policy gradients (Lillicrap et al. 2015), as follows: where θd is the parameters ofd andd(s, a|θd) is updated based on Equation (6). To stabilize the policy training, we also create copies θ µ and θ d for the actor networks θ µ and the critic networks θd. For exploration, we can construct an exploration policy µ by adding Gaussian noise to the target policy µ, i.e., µ (s t ) = µ(s t |θ µ ) + N , where N can be chosen to suit the environment, e.g., based on domain knowledge of the environment.
Based on the theoretical and conceptual insights developed above, we now present Deterministic and Discriminative Imitation (D2-Imitation), an off-policy imitation learning method that trains a deterministic policy with a discriminator. During training, the algorithm proceeds as follows: It first populates B + with all demonstration state-action pairs (s E , a E ), and then generates random actions a rnd for each state s E in B + . In the next step, it trains the discriminator parametrized with ψ, D ψ , with positive samples from B + and random samples (s E , a rnd ). In the policy training, whenever a sample (s, a) is generated by rolling out the policy in simulation, the discriminator then determines which buffer the sample should be put in. We set a probability threshold Predict probability p of (s, a) being positive with D ψ .

7:
if p ≥ P th then 14: Update θd, θ µ based on Equation (6) end if 18: end for P th such that (s, a) is put into B + only when the probability given by D ψ exceeds P th . Otherwise, the sample (s, a) is put into B 0 . In the following steps, D2-Imitation assigns a constant positive reward 1 to all samples in B + , and zero reward to those in B 0 , and updates the distribution proxy θd and the policy θ µ based on Equation (6) and Equation (7) respectively. D2-Imitation is detailed in Algorithm 1.
Compared to adversarial imitation approaches, D2 differs in the following perspectives: First, D2 does not assume the expert demonstrations are from a stationary state-action distribution. In other words, D2 only requires the samples to be from a conditional distribution π E (a|s) rather than from d E (s, a). Consequently, D2 learns a discriminator which conditions on the state, whereas adversarial imitation approaches train a discriminator for joint state-action pairs. Second, D2 leverages TD learning to directly approximate a proxy to the BFSs, while adversarial imitation approaches rely on density ratio estimation, which involves variational estimate of a divergence (Nguyen, Wainwright, and Jordan 2010) that generates non-stationary rewards in training.
The above analysis for D2-Imitation assumes that the expert policy is deterministic such that BFSs are the same for Equations (4) and (5). If the expert policy is stochastic, the notion of learning a deterministic policy in effect considers the setting that only one feasible action should be learned. For apprenticeship learning in large or continuous state spaces, e.g., continuous control tasks, it is exceedingly unlikely to have the exact same state twice in the demonstrations. Thus, learning deterministic policies in apprenticeship learning effectively amounts to distilling one-one mappings from demonstrations. In the next section, we show that D2-Imitation still works well empirically even when the given demonstrations are generated by stochastic policies.

Experiments
We evaluate D2-Imitation on several popular benchmarks for continuous control. We first use four physics-based con-trol tasks: Swimmer, Hopper, Walker2d and HalfCheetah, ranging from low-dimensional control tasks to difficult highdimensional ones. Each task comes with a true cost function (Brockman et al. 2016). We first generate expert demonstrations by running state-of-the-art RL algorithms, including Soft Actor Critic (SAC) (Haarnoja et al. 2018), Proximal Policy Optimization (PPO) (Schulman et al. 2017), Deep Deterministic Policy Gradient (DDPG) (Lillicrap et al. 2015), and Twin-Delayed DDPG (TD3) (Fujimoto, van Hoof, and Meger 2018), on the true cost functions. We train five different policies using independent seeds for three million time steps. To collect demonstrations, we roll out each expert policy to gather 20 trajectories and for each environment we have 100 trajectories altogether. Then, to evaluate imitation performance, we sample a certain number (5, 10, 15, or 20) of trajectories as demonstrations. This procedure repeats for other domains, including classic controls and Box2D simulation. For the critic and actor networks, we use a two layer MLP with ReLu activations (tanh activation for the last layer in the actor network) and two hidden units (256+256). For the discriminator we use the same architecture as Ho and Ermon (2016): a two layer MLP with 100 hidden units and tanh activations. These design choices have been empirically shown to be best suited to control tasks. We train all networks with Adam (Kingma and Ba 2014) with a learning rate of 10 −3 . The discriminator is pretrained for 1000 iterations with batch size 256. We set the probability threshold heuristically to 0.8 (after a sweep from 0.7 to 0.95) as it empirically works well across all domains. In positive buffer B + , we force the off-policy samples to account for only a small portion ( 25%), and the majority is still from demonstrations. The implementation of off-policy TD follows that of TD3 (Fujimoto, van Hoof, and Meger 2018), with a double Q-net.

Comparing to Adversarial Imitation Methods
We first compare our algorithm to two extensions of adversarial imitation: discriminator-actor-critic (DAC) (Kostrikov et al. 2018), and Random Expert Distillation (RED) (Wang et al. 2019), Particularly, DAC addresses sample efficiency by reusing past experiences through a replay buffer, while RED does so by stabilizing RL training with a fixed reward function, rather than the non-stationary one in GAIL. We use the original implementation of DAC and RED. 2 DAC also adopts the following practice to improve sample efficiency: a replay buffer and the deterministic policy updated via TD3 algorithm. We also compare the proposed algorithm with a variant of GAIL in which the policy is pre-trained with behavior cloning (BC) to reduce the sample complexity, as used by Ho and Ermon (2016). We tune the number of pre-training iterations for different environments to achieve stable performance. We also found that too many iterations hinder learning of GAIL as the behavioral cloning may overfit to the demonstration data. We perform evaluation using 10 random seeds. For each seed, we log average episodic returns from the simulation environment in training. Like Ho 2 DAC: https://github.com/google-research/google-research/ tree/master/dac; RED: https://github.com/RuohanW/RED. and Ermon (2016) and Kostrikov et al. (2018), we plot returns normalized by expert performance. We compute means over all seeds and visualize standard deviations. Figure 2 shows that D2 is much more sample efficient than the pre-trained GAIL and RED in all tested environments with SAC demonstrations. GAIL's performance is worse than reported in (Ho and Ermon 2016) as the original GAIL was trained for ≥2M timesteps for Hopper and Swimmer, and ≥25M for HalfCheetah, while the figure presents results for training with only 100K timesteps. Furthermore, D2 achieves expert performance with fewer samples than DAC and recovers the expert policy on environment Walker2d and Swimmer. D2 also performs slightly better on Hopper and trains more stably than DAC. On HalfCheetah, D2 does not outperform DAC but both algorithms converge slowly with the given demonstrations. After comparing HalfCheetah demonstrations with the ones for other tasks, we found action values demonstrated by SAC policies in HalfCheetah task are mostly near 1.0 or −1.0 (torque limits), which could make it difficult for a policy network with tanh as the output activation to approximate.
We also vary the number of demonstration trajectories, as shown in Figure 3. The average performance is reported for each algorithm (10 repeats) after training with only 100K environment interactions. D2 consistently outperforms all other methods in Walker2d, Swimmer and Hopper with different numbers of demonstration trajectories, with statistical significance on Walker2d, Swimmer and Hopper.
We further evaluate D2 and DAC with 20 trajectories on two more domains, classic controls and Box2D. Results are presented in Table 1. D2 significantly outperforms DAC after training only for 50K time-steps, and also significantly faster than DAC in wall clock time (as D2 requires no training of any reward function).

Comparing With Off-policy Distribution Matching
Second, we compare D2 with ValueDICE (Kostrikov, Nachum, and Tompson 2019), the state-of-the-art off-policy distribution matching approach for imitation learning. Val-ueDICE leverages the change of variable trick to turn the on-policy distribution matching problem into an off-policy optimization problem. However, as pointed out by Sun et al. (2021), such change of variable implicitly assumes that the on-policy samples should be strictly sampled from a stationary state-action distribution. Otherwise, the off-policy optimization objective would be biased in practice. We thus evaluate D2-Imitation and ValueDICE on demonstrations generated by different RL algorithms. Specifically, in addition to the expert trajectories generated in previous evaluation, we further use 20 trajectories by policies trained via TRPO,DDPG and TD3. 3 Policies in TRPO and SAC are stochastic while those in DDPG and TD3 are deterministic. We then evaluate D2 and ValueDICE on these four types of demonstrations. Figure 4 presents the training performance of two algorithms on the HalfCheetah environment (we pick HalfCheetah as it was reported that learning the expert policy could take more than 20 million timesteps for imitation learning methods (Kostrikov et al. 2018)). Although ValueDICE achieves good sample efficiency with demonstrations given by TRPO (stochastic policies), its performance becomes worse when demonstrations change. Empirically, ValueDICE is sensitive to demonstrations, and can fail to learn the expert policy. For example, ValueDICE initially progresses on DDPG demonstrations, then plateaus after 50K time-steps and never reaches expert performance. Furthermore, we found that even with demonstrations that are generated by stochastic policies, e.g., SAC, D2 still outperforms ValueDICE. Intuitively, this could be because a stochastic policy can always be turned into deterministic by picking the best or mean action, the discriminator in D2 is trained to predict that action for each state, and off-policy TD learns a deterministic policy that distills such action information from replay buffers. Overall, compared with Val-ueDICE, the performance of D2 imitation is more consistent across different types of demonstrations.

Ablation Studies
The discriminator is crucial for D2-Imitation to work properly and guarantees convergence to expert performance. We perform ablations on the discriminator and compare the training performance of D2-Imitation with one variant: one without any discriminator (denoted without-discriminator), which just puts on-policy samples to B 0 , assigns 0 reward to them and gives +1 reward to demonstration samples in B + , an idea adopted in Soft-Q Imitation Learning (SQIL) (Reddy, Dragan, and Levine 2019). Figure 5 shows that training quickly plateaus or even collapses if no discriminator is applied. Furthermore, this plateauing effect happens more quickly when fewer demonstration trajectories are used. This phenomenon has also been reported in SQIL.
To avoid such training collapse, SQIL requires early stopping of the training process by judging whether the squared soft Bellman error converges to a minimum, which we ar-  gue can be challenging as this early stopping also relates to the number of trajectories used in training. Moreover, even with perfect early stopping (say 100K interactions as in the given figure in which the true reward function is known), the policy still fails to achieve the expert performance.

Related Work
Adversarial imitation casts imitation learning as a distribution matching problem (Ho and Ermon 2016) and leverages GANs (Goodfellow et al. 2014) to minimize the Jensen-Shannon divergence between distributions induced by the expert and the learning policy. This approach avoids the difficulty of learning reward functions directly from demonstrations but is generally sample intensive. To improve sample efficiency, many methods extend adversarial imitation to be off-policy. For instance, Discriminator-actorcritic (DAC) (Kostrikov et al. 2018;Sasaki, Yohira, and Kawaguchi 2018) improves sample efficiency by reusing previous samples stored in a relay buffer. However, this approach still relies on non-stationary reward signals generated by the discriminator, which can make the critic estimation hard and training unstable. Recent work proposes to train a fixed reward function by estimating the support of demonstrations and training critics with the fixed reward (Wang et al. 2019). This support estimation itself could be hard given that only a limited number of empirical sam-ples are available from the considered distributions. Another line of off-policy distribution matching approaches focuses on estimating the critics directly without learning any reinforcement signals (Sasaki, Yohira, and Kawaguchi 2018;Kostrikov, Nachum, and Tompson 2019). The state-of-theart along this line is ValueDICE (Kostrikov, Nachum, and Tompson 2019), which casts distribution matching as offpolicy density ratio estimation and updates the policy directly via a max-min optimization. However, as we show in the analysis and experiments, these methods can be ill-posed when the demonstrations are generated from deterministic policies, and their performance can also be sensitive to the demonstrations used in training.
Recently, some non-adversarial imitation learning approaches have been proposed. For example, offline nonadversarial imitation learning (Arenz and Neumann 2020) reduces the min-max in ValueDICE to policy iteration, which however still requires estimating density ratios and can potentially inherit the same issues from ValueDICE. By contrast, D2-Imitation avoids density ratio estimation and is more robust to different demonstrations. Primal Wasserstein imitation learning (Dadashi et al. 2020) avoids adversarial training by introducing an off-line cost function, which, however, requires a domain-specific metric and can be challenging to properly specify for different environments. D2-Imitation does not need such domain knowledge and can be applied in many different settings. Our reward design for D2-Imitation looks superficially similar to that of Soft Q Imitation Learning (SQIL), which assigns +1 reward to demonstration and zero for all interaction samples (Reddy, Dragan, and Levine 2019). However, D2-Imitation is fundamentally different in that the reward assignment is theoretically consistent with the use of deterministic policies.

Conclusion
In this paper, we revisited the foundations of adversarial imitation. We leveraged the similarity between the Bellman equation and the stationarity equation to derive a TD learning approach, which directly learns a special proxy, i.e., basic feasible solutions, for the expert state-action distribution. Moreover, we showed that the use of deterministic policies simplifies TD learning and yields a practical learning algorithm, D2-Imitation, which operates by first partitioning samples into two replay buffers and then learning a deterministic policy via off-policy deterministic policy gradients. Finally, the notion of partitioning samples into two groups theoretically follows from the use of a deterministic policy. Our empirical results demonstrated that D2-Imitation is effective in achieving good sample efficiency, and outperforms many adversarial imitation approaches on different control benchmark tasks with demonstrations generated by either deterministic or stochastic policies. Also, D2-Imitation consistently outperforms the state-of-the-art off-policy distribution matching method when training with various different types of demonstrations. In conclusion, D2-Imitation, as a direct result of leveraging two novel insights in the distribution matching formulation, is a simple yet very effective sample-efficient imitation learning approach.