Abstract
Reinforcement Learning (RL) is an effective approach to solve sequential decision making problems when the environment is equipped with a reward function to evaluate the agent’s actions. However, there are several domains in which a reward function is not available and difficult to estimate. When samples of expert agents are available, Inverse Reinforcement Learning (IRL) allows recovering a reward function that explains the demonstrated behavior. Most of the classic IRL methods, in addition to expert’s demonstrations, require sampling the environment to evaluate each reward function, that, in turn, is built starting from a set of engineered features. This paper is about a novel model-free IRL approach that does not require to specify a function space where to search for the expert’s reward function. Leveraging on the fact that the policy gradient needs to be zero for an optimal policy, the algorithm generates an approximation space for the reward function, in which a reward is singled out employing a second-order criterion. After introducing our approach for finite domains, we extend it to continuous ones. The empirical results, on both finite and continuous domains, show that the reward function recovered by our algorithm allows learning policies that outperform those obtained with the true reward function, in terms of learning speed.
Introduction
Reinforcement Learning (RL) [49] assumes that the implicit notion of “task” (or goal) is encoded in a Markov Decision Process (MDP) [46] by means of the reward function. Provided that the environment is equipped with a reward function, RL offers a wide range of algorithms to estimate an optimal policy, when the dynamics of the environment is unknown [49]. However, there are several real-world cases in which manually devising a reward function is a challenging problem. The classic motivating example, proposed by Abbeel and Ng in [1], is the car driving problem. Specifying a suitable reward function means, in this case, formalizing the intuitive notion of “driving well”. Driving is a complex multi-objective task: a good driver trades off many conflicting desiderata, such as keeping a reasonable speed, staying far from any pedestrian, maintaining a safe following distance. The authors claim that, rather than specifying a reward function, it is easier to generate demonstrations of good drivers, inducing the agent to learn by observation. Learning from expert’s demonstrations is called Apprenticeship Learning (AL), also named learning by watching, imitation learning, or learning from demonstration.
The main approaches for solving this problem are Behavioral Cloning (BC) [2] and Inverse Reinforcement Learning (IRL) [39]. The former recovers the demonstrated policy by learning the state-action mapping in a supervised learning way, while inverse reinforcement learning aims to learn a reward function that makes the expert optimal. Behavioral cloning is simple, but its main limitation is the intrinsic goal, i.e., to replicate the observed policy. This has several drawbacks: it requires a huge amount of data when the environment (or the expert) is stochastic [22]; it does not provide good generalization or a description of the expert’s goal. On the contrary, inverse reinforcement learning accounts for generalization and transferability by directly learning a reward function. This information can be transferred to any new environment; as a consequence, IRL allows recovering an optimal policy a posteriori, even under variations of the environment. Furthermore, the expert’s policy might be very far from the class of policies that the learner can play (e.g., a human demonstrator and a robotic learner). Therefore, the best policy recovered by behavioral cloning could display worse performance w.r.t. a policy learned by optimizing a reward function of the problem. IRL has received a lot of attention in the literature and has succeeded in several applications [e.g., 1, 17, 23, 48, 52, 62].
It is important to stress that the reward function is more powerful and compact information w.r.t. the optimal policy. The transition model can change over time, due to external factors, as a consequence also the optimal policy might change. However, the reward encodes the notion of “task” and thus, it will remain the same. Knowing the reward, we can recompute an optimal policy associated with the new MDP. Nevertheless, BC and IRL are tightly related by the intrinsic relationship between reward and optimal policy. The reward function defines the space of optimal policies and to recover a reward it is required to observe/recover an optimal policy. However, also IRL approaches pose some relevant challenges. First, several IRL methods require solving the forward RL problem as part of an inner loop in order to evaluate the quality of each candidate reward [e.g., 1, 52]. Literature has extensively focused on removing this limitation [28, 44, 45] in order to scale IRL to real-world applications [16, 21, 22]. Second, IRL methods generally require designing the function space by providing features that capture the structure of the reward function [e.g., 1, 3, 28, 45, 47, 52, 54]. This information, provided in addition to expert’s demonstrations, is critical for the success of the IRL approach. The issue of designing the function space is a well-known problem in supervised learning, but it is even more critical in IRL since a wrong choice might prevent from finding good solutions to the IRL problem [37, 39], especially when linear reward models are considered. The importance of incorporating feature construction in IRL has been known in the literature for a while [1], but, as far as we know, it has been explicitly addressed only in [29]. Recently, IRL literature, by mimicking supervised learning one, has focused on exploiting the neural network capability of automatically constructing relevant features out of the provided data [e.g., 16, 21, 23]. By exploiting a “black-box” approach, these methods do not take advantage of the structure of the underlying Markov decision process (in the phase of feature construction).
In this paper, we revise Compatible Reward Inverse Reinforcement Learning (CR-IRL), an algorithm that constructs reward features directly from expert’s demonstrations. CR-IRL is model-free and does not require solving the forward problem (i.e., finding an optimal policy given a candidate reward function) as an inner step. The algorithm builds a reward function that is compatible with the expert’s policy. It mixes BC and IRL in order to recover the “optimal” and most “informative” reward function in the space spanned by the recovered features. Inspired by the gradient-minimization IRL approach proposed in [45], we focus on the space of reward functions that makes the policy gradient of the expert vanish. Since a zero gradient is only a necessary condition for optimality, we consider a second order optimality criterion based on the policy Hessian to rank the reward functions and finally select the best one (i.e., the one that penalizes the most a deviation from the expert’s policy). This work is an extension of [36] and the main contributions are: i) a deeper analysis of the problem of estimating the expert’s policy (Section 4); ii) a more detailed discussion of the second-order criteria for recovering the reward function, including a multi-objective view of the problem (Section 6); iii) a theoretical analysis of the algorithm, including a computational complexity analysis and a finite-sample analysis of the feature extraction phase (Section 7); iv) a wider experimental campaign including new experiments and a new domain (Section 9).
Preliminaries
A Markov Decision Process (MDP) [46] is defined as a tuple
We consider the case in which the policy belongs to a parametric policy space Π
Θ
= {π
θ
: θ ∈ Θ ⊆ IR
k
} and we denote with J (θ) the quantity
We now discuss how the expected return can be actually computed, introducing the trajectory view and the state-action view.
Consider a policy π
θ
and suppose to run π
θ
for H ∈ IN ∪ {+ ∞} time steps in the environment.
1
In this process, we will encounter a sequence of states and actions, namely a trajectory. We will denote with
A policy π
θ
, combined with the transition model P and the distribution of the initial state μ, generates a visiting distribution of the states of the MDP. We define the γ-discounted state distribution
Furthermore, when we are not interested in the initial state distribution μ, we can define the state value function [49] as the expected return obtained by starting in state s and following policy π
θ
thereafter (Bellman equation):
In this section, we provide a high-level overview of CR-IRL. CR-IRL takes as input a parametric policy space Π
Θ
and a set of trajectories
IRL literature usually considers two different settings: optimal or sub-optimal expert. This distinction is necessary when a fixed reward space is provided, knowing that an optimal expert would maximize a reward within that space. If the demonstrated behavior happens to be suboptimal, then the IRL problem becomes somehow not well defined and might result infeasible, as the reward actually optimized by the (suboptimal) expert might fall outside the considered space. In this case, additional “optimality” criteria are required [37]. This is not the case for CR-IRL that is able to automatically generate the space of reward functions that make the policy gradient vanish. In this way, the space would contain also reward functions under which the recovered expert’s policy π
Estimating the expert’s policy
Approximating the expert’s policy π
E
can be formulated as a probability estimation problem, solved by exploiting the available expert’s trajectories
In the following, we will consider only the ML approach. It is well known that rather than optimizing the likelihood function
It is worth noting that the ML policy π
θ
ML
, even if we have infinite samples, is not necessarily the optimal policy π
θ
*
in the policy space Π
Θ
, i.e., the policy that maximizes the expected return, as defined in equation (2). When the policy space Π
Θ
is sufficiently expressive to contain the expert’s policy, i.e., there exists θ
E
∈ Θ such that π
E
= π
θ
E
, ML policy converges almost surely to the expert’s policy. On the contrary, when the expert’s policy falls outside Π
Θ
, π
θ
ML
converges the moment projection of π
E
onto Π
Θ
[11]:
In this section, we present the procedure to obtain the set
We assume the space
The parametrization of the expert’s policy influences the size of
A first important note is that the policy rank depends not only on the policy model Π Θ , but also on the value of the parameters of the policy π θ . So the policy rank is a property of the policy not of the policy model. The following bound on the policy rank holds for finite MDPs.
From an intuitive point of view this is justified by the fact that π
θ
(· |s) is a probability distribution. As a consequence, for all
The bound on the policy rank does not assume any information about the optimality of the policy within the class Π Θ . Γ π θ might lose further dimensions when π θ is obtained as the maximum likelihood policy from the set of expert’s trajectories.
5.2. Expert’s compatible Q-features
In this section, we discuss how to construct the features for representing the optimal Q-function, for both finite and continuous MDPs.
5.2.1. Construction of ECO-Q in finite MDPs
We now develop in details the algorithm to generate ECO-Q in the case of finite MDPs. From now on we will indicate with
5.2.2. Construction of ECO-Q in continuous MDPs
To extend the previous approach to the continuous domain we assume that the state-action space is equipped with the Euclidean distance. Now we can adopt an approach similar to the one exploited to extend Proto-Value Functions (PVF) [30,31] to infinite observation spaces [32]. The problem is treated as a discrete one considering only the state-action pairs visited along the collected trajectories. A Nyström interpolation method is used to approximate the value of a feature in a non-visited state-action pair as a weighted mean of the values of the closest k features. The weight of each feature is computed by means of a Gaussian kernel placed over the Euclidean space
5.3. Expert’s compatible reward features
The set of ECO-Q basis functions allows representing the optimal value function under the policy π θ . In this section, we will show how it is possible to exploit ECO-Q functions to generate basis functions for the reward representation.
We propose two approaches: the first is based on explicit application of Bellman equation and requires the knowledge of the transition model; the second is model-free and exploits optimality-invariant reward transformations. The obtained features, named Expert’s COmpatible Reward features (ECO-R), still satisfy the first-order optimality condition.
5.3.1. Model-based construction of reward features
The relation between the reward and theQ-function is given by the Bellman Equation (7). Considering only the state-action pairs visited along the available expert’s trajectories
5.3.2. Model-free construction of reward features
Reversing the Bellman equation allows finding the reward space that generates the estimated Q-function. However, IRL is interested in finding just a reward space under which the expert’s policy is optimal. This problem can be seen as an instance of reward shaping [38] where the authors show that the space of all the reward functions sharing the same optimal policy is given by:
In the next section, we propose a new method to single out a unique reward function, based on the optimization of a second-order criterion that favors reward functions that significantly penalize deviations from the expert’s policy. Once the ECO-R basis functions have been generated, they can be used, in principle, to feed any IRL algorithm that represents the expert’s reward through a linear combination of basis functions. We will show empirically, that the best performances are obtained when coping our feature construction with the reward selection presented below.
Any linear combination of the ECO-R
To retain only maxima we need to impose that the Hessian is negative definite which is equivalent to require that the maximum eigenvalue
In our framework, the reward function can be expressed as a linear combination of the ECO-R so we can rewrite the Hessian as:
Being the Hessian symmetric and defined through an affine function of the variables ω, the maximum eigenvalue is convex [41]. This is a consequence of the fact that we can define
This optimization problem is for sure feasible (for sufficiently small κ) since, as already seen, the true reward function and the advantage function make the expert’s policy parametrization optimal. However, in most of the cases, it is impractical to solve, at least for two reasons. First, the computational effort is enormous even for few policy parameters. Second, it might be the case that the strict negative definiteness constraint is never satisfied due to blocked-to-zero eigenvalues. This problem arises quite often and is related to the presence of “useless” policy parameters that even if modified do not affect the policy performance (for instance, a subset of parameters which are linearly dependent). In those cases
In order to account for the possible presence of blocked-to-zero eigenvalues, we need to consider all the eigenvalues of the Hessian matrix instead of the maximum one only. When in the direction of minimum curvature the curve is flat (like in case of blocked-to-zero eigenvalues) we aim to maximize an index of the overall concavity. The trace of the Hessian, being the sum of the eigenvalues, can be used for this purpose. Minimizing the trace of the Hessian (Trace Optimality Criterion, TR-opt) can be formulated in the following semi-definite programming problem:
Solving the semidefinite programming problem of one of the presented optimality criteria is unfeasible for almost all the real world problems. We are interested in formulating a non-SDP problem, which is a surrogate of the trace optimality criterion, that can be solved more efficiently (Trace Heuristic Criterion, TR-heu). Essentially, we need to get rid of the semi-definiteness constraint.
We assume that the ECO-Rs are orthonormal in order to compare them. 6 The main challenge is how to select the weight ω in order to get a (near-)optimal trace minimizer that preserves the negative semi-definiteness constraint.
Given two symmetric matrices
Notice that, in this way, we can lose the optimal solution since the trace minimizer might assign a non-zero weight to an ECO-R with indefinite Hessian. For brevity, we will indicate with
6.4. Multi-objective interpretation of the second-order criteria
The intuitive idea behind the second-order criteria we presented in the previous sections consists in preferring rewards that penalize the most deviations from the expert’s policy. This notion can be formalized, in the general case, as the multi-objective SDP problem of minimizing the vector of eigenvalues of the policy Hessian:
It is worth noting that the maximum eigenvalue and the trace optimality criteria fall in this formulation. The former is obtained by setting ξ1 = 1 and ξ i = 0, i = 2, 3, . . . , k, while the latter is obtained by setting ξ i = 1, i = 1, 2, . . . , k. Therefore, we are sure that those criteria provide Pareto optimal solutions. Furthermore, the two criteria correspond to popular solution concepts in multi-agent decision theory [57]. The maximum eigenvalue optimality criterion recovers the egalitarian social welfere solution, i.e., the solution that minimizes the maximum unsatisfaction, whereas the trace optimality criterion seeks for the utilitarian solution, i.e., the solution that maximizes the sum of profits. The trace heuristic, however, does not guarantee that the recovered solution is Pareto optimal.
Furthermore, the single-objective function (26) is not convex for all values ofξ. It can be proved that a sufficient condition for convexity is that ξ1 ≥ ξ2 ≥ . . . ≥ ξ k ≥ 0 [34], to which both maximum eigenvalue and trace optimality criteria comply.
CR-IRL does not assume to know the state space
Refer to Algorithm 1 for a complete overview of CR-IRL.
In this section, we provide an analysis of the computational complexity of CR-IRL together with a finite-sample analysis of the feature extraction phase.
Computational complexity analysis
The main sources of computational complexity in CR-IRL are the SVD, the computation of the Hessian and its eigenvalue computation for each ECO-R. For an m × n matrix it is well known that SVD has complexity
Finite-sample analysis
In this section, we perform an error analysis of the feature extraction phase. In particular, our goal is to bound the ℓ2-norm of the difference between an ECO-Rψ extracted using the actual expert policy π
E
and an infinite number of samples and an approximate ECO-R
the state space the expert’s policy π
E
belongs to Π
Θ
, i.e., there exists θ
E
∈ Θ such that π
E
= π
θ
E
; for any policy π
θ
∈ Π
Θ
, for any the ∇
θ
log π
θ
is Lipschitz continuous w.r.t. the policy π
θ
in the following sense:
We start by analyzing the error propagation for the ECO-Qs. Our goal is to provide a bound for the ℓ2-norm of the difference between a given ECO-Qϕ and its estimate
If we take
As intuition suggests, a more precise estimation of matrix
The ℓ2-norm of the difference between
We can now provide a finite-sample bound for the quantity
For the estimator (15), the derivation is analogous. We do not have to decompose the contribution of the policy, but we just need to bound the bias (the proof is identical to the one presented above, just summing over the state-action space) and apply [58] recalling that this second estimator is defined over the state-action space.□
The following result provides a bound of the ℓ2-norm of the error in the estimation of an ECO-R ψ given the ℓ2-norm of error in the estimation of the corresponding ECO-Q ϕ.
Proof.
As the ECO-Rs are computed starting from the ECO-Qs by means of a linear mapping involving the policy, the bound depends not only on the error in the estimation of the ECO-Qs but also on the error in the policy representation. It is worth to notice that this transformation is likely to amplify the error due to the multiplication for
IRL approaches can be classified according to several dimensions. A first notable dichotomy is between model-based and model-free algorithms. The former, such as [39, 52, 62], are hardly deployable to real-world applications since they require to have access to a representation of the environment transition model P. The estimation of the transition model is particularly challenging when the state (or action) space is continuous, but it is even more difficult if we have only expert’s demonstrations at our disposal. An expert is typically an optimal (or near-optimal) agent, thus it is going to explore a very limited region of the state space, resulting in poor estimation of the transition model. As an alternative, we could collect trajectories using an explorative (e.g., random) policy, but this would potentially increase the execution cost. Other methods, like feature expectation algorithms [1, 53], do not require explicitly the transition model even if they need to sample the environment in order to solve the forward reinforcement learning problem. These algorithms belong to a gray zone in between model-based and model-free.
A limited number of algorithms can be defined really model-free. On one hand, structured classification methods [27, 28] deal with the IRL problem with no need for interaction with the environment, apart from collecting expert’s demonstrations. These methods cast the problem of recovering the reward function into a multi-class classification problem, possibly formulated in multiple stages [28]. The approaches based on the policy gradient, like GIRL [45], SOME-IRL [54] and CR-IRL [36] are able to recover a reward function from a set of expert’s trajectories only, as well. However, these methods, differently to the structured classification approaches that resort to supervised learning, explicitly take advantage of the structure of the underlying MDP.
Another relevant issue is reward ambiguity. The choice of a reward function among all feasible ones is, of course, related to the notion of optimality we decide to employ. Indeed, literature has not treated this issue in a comprehensive way yet. Intuitively, we aim to find a reward with “good” learning properties, i.e., a reward able to learn the optimal policy quickly. However, the learning speed is an algorithm-dependent property. Maximum Entropy Inverse Reinforcement Learning (ME-IRL) [61, 62] dealt with this issue explicitly, proposing an optimality criterion based on the maximum entropy principle, in which we prefer a reward function that imposes as few constraints as possible on the optimal policy if not justified by the expert’s choices. Similarly, Relative Entropy Inverse Reinforcement Learning (RE-IRL) [10] extends ME-IRL removing the need of knowing the full environment model, still requiring a dataset collected with an explorative policy.
The choice of the reward approximation space is a further issue. Early IRL methods had a preference for linear parametrizations, most of them work with linear parametrizations only [e.g., 1, 52]. Resorting to linear models is risky for, essentially, two reasons. First, a linear model might not be able to learn the possibly complex dynamics going on in the features. Second, a bad choice of the features might harm the process of reward recovery. Research tried to tackle both problems. Algorithms able to generate automatically the feature space overcome the latter problem. Indeed, with a good feature construction mechanism, even a linear model is effective. Instead, linear approximators are replaced with expressive non-linear neural networks in deep learning approaches to IRL [e.g., 16, 21, 23] which are able to deal with both problems at once. These approaches, however, tend not to fully exploit the Markovian nature of the underlying environment. In particular, in [16], Guided Cost Learning is proposed to deal with the IRL problem in complex continuous environment without assuming the knowledge of the true environment model, by employing deep function approximates. The algorithm extends ME-IRL and combines forward RL. The idea behind this approach is to progressively change the sampling distribution in order to match the maximum entropy distribution. In this way, the algorithm exploits the expressive power of the neural networks to learn, jointly, the features and the reward function. Differently, CR-IRL keeps the feature construction and the reward selection phases separated and performs them in sequence. For this reason, once we extracted the informative features for the reward (ECO-R) we can simply use linear models for building the reward function, without making use of complex function approximators. In the same direction of extending ME-IRL, in [17] Adversarial Inverse Reinforcement Learning (AIRL) is presented as an approach based on the adversarial framework [20] that allows learning the reward function and the value function simultaneously. The authors claim that by using a reward function depending on the state only, they are able to mitigate the ambiguity problem by learning rewards that are independent from the underlying environment dynamics. Similarly, in [56] an approach to tackle the IRL problem in Linearly solvable MDPs [55] is presented. The IRL problem is formulated as a density ratio estimation between the optimal state transition and a baseline and, finally, solved via logistic regression.
At best of our knowledge, the only IRL method that directly tackles the feature construction problem is Feature Construction for Inverse Reinforcement Learning (FIRL) [29]. FIRL alternates between optimization and fitting phases. The optimization phase aims to recover a reward function, from the current feature set as a linear projection, such that the associated optimal policy is consistent with the demonstrations. In the fitting phase, new features are created (using a regression tree) in order to better explain regions where the old features were too coarse. The method proved to be effective in achieving also (features) transfer capabilities. However, FIRL requires the MDP model to solve the forward problem and the complete optimal policy for the fitting step in order to evaluate the consistency with demonstrations. We believe that this might represent a significant limitation, especially in scenarios in which accessing the environment is costly, dangerous or even impossible (e.g., critical industrial applications). Differently, CR-IRL is fully model-free, being able to recover an approximation space for the reward function and selecting a unique reward within this space, by employing the set of expert’s demonstrations solely.
Experimental evaluation
This section is devoted to the experimental evaluation of CR-IRL on classic benchmark problems, both discrete and continuous: the Taxi problem (Section 9.2), the Linear Quadratic Gaussian Regulator (Section 9.3) and the Car on the Hill environment (Section 9.4).
We compare CR-IRL with classic IRL algorithms in order to evaluate the performance of the recovered reward functions. In particular, the experiments are intended to evaluate both the phases of CR-IRL: the feature construction and the reward recovery. For the feature construction phase, we compare the ECO-R with a predetermined set of features automatically generated (like Proto-Value Function, PVFs [31]); while for the reward recovery phase we evaluate CR-IRL against popular state-of-the-art IRL algorithms able to output a reward as a linear combination of features when fed with ECO-R.
We start presenting the evaluation metrics we adopt to compare the considered algorithms (Section 9.1) and then we report the full results of the experiments.
Evaluation metrics
Defining a metric to evaluate the intuitive notion of “good reward” is a hard task and literature has not formalized it yet. Intuition suggests that we should recover a reward function that allows the agent to learn a policy as close as possible to the expert’s policy. However, there are problems in which even if the learned policy and the expert’s policy are significantly different the average return is very close, and vice versa. In other words, a small policy deviation might attain a large return deviation. Furthermore, all other things being equal, we should prefer a reward function with a faster learning curve. Clearly, this last property is algorithm-dependent. For these reasons we resort to multiple metrics:
learning speed: the number of iterations of the forward RL algorithm needed for converging to the optimal policy;
average return: the average return
policy distance: the distance between the expert’s policy π
E
and the learned policy
parameter distance: when both the expert’s policy and the learned policy are parametric policies of the same class, the distance (in norm) between the expert’s parameters θ
E
and the learned parameters
Taxi
This section is devoted to the experiments performed on the Taxi domain, defined in [13]. The environment corresponds to a 5×5 grid in which there are 4 locations, labeled by different letters (R, G, B, and Y). The job of the taxi driver is to pick up the passenger at one location and drop him off in another. The agent receives +20 points for a successful dropoff and loses 1 point for every timestep it takes. There is also a 10 point penalty for illegal pick-up and drop-off actions. The available actions are the movements in the four directions (North, East, South, West), pick-up and drop-off (all actions are deterministic). The passenger position, the destination position and the initial position of the taxi represent the state. The distribution of the initial state is uniform and the discount factor is 0.99.
We compute the optimal deterministic policy via value iteration [6] and we use it to fit, via maximum likelihood (with ridge regularization on the parameters), the parameters of expert’s policy, belonging to the class of ε-Boltzmann policies with fixed ε:
9

Singular values of the ∇ θ log πθ,ε. When ε = 0 the gap between non-zero and zero singular values is clear; while the behavior is smoother when ε = 0.1 but the magnitude of the singular values is significantly smaller.
We compare the performance of CR-IRL with trace heuristics criterion, 10 against Behavioral Cloning (BC), obtained by recovering the maximum likelihood Boltzmann policy from expert’s trajectories, Maximum Entropy IRL (ME-IRL) [62], Relative Entropy IRL (RE-IRL) [10] and Linear Programming Apprenticeship Learning (LPAL) [52].
In order to recover the set of ECO-R we collect 100 expert’s trajectories. For this experiment we evaluate both model-free and model-based versions of CR-IRL. For the latter case the transition model is estimated from expert’s trajectories via the Monte Carlo estimator:
Implementation issues. In the Taxi domain when the agent reaches the terminal state it will receive zero reward forever. However, the reward function recovered by CR-IRL could assign a non-zero reward to the terminal state. For implementation reasons, we translate the recovered reward in order to ensure zero-reward to the terminal state. Furthermore, the recovered reward function is extended to the unvisited state-action pairs assigning the minimum value among the rewards of the visited state-action pairs.
Learning speed experiments. This set of experiments is meant to compare the learning speed of the reward functions recovered by the considered IRL methods when a Boltzmann policy (ε = 0) is trained with REINFORCE [59]. The training is performed with Adam [26] (learning rate 0.008, other parameters with default value), at each iteration 100 trajectories are used to estimate the gradient and the initial parameter is θ(0) =
Figure 2 shows that model-free CR-IRL, with 100 expert’s trajectories, outperforms the original reward function in terms of convergence speed regardless of the exploration level. Behavioral Cloning (BC), obtained by recovering the maximum likelihood ε-Boltzmann policy from expert’s trajectories, is very susceptible to noise, as expected, for both values of ε. Similarly, Linear Programming Apprenticeship Learning (LPAL) [52] using as reward features the set of model-free ECO-R is unable to reach the optimal performance. Indeed, LPAL provides as output an apprenticeship policy (not a reward function) and, like BC, is very sensitive to noise and to the quality of the estimated transition model.

Average return of the Taxi problem as a function of the number of iterations of REINFORCE for model-free ECO-R.
We also compare, in Fig. 2, the second-order criterion of CR-IRL to single out the reward function with Maximum Entropy IRL (ME-IRL) [62] and Relative Entropy IRL (RE-IRL) [10] using as reward features the set of model-free ECO-R. We can see in Fig. 2 that ME-IRL does not perform well when ε = 0, since the transition model is badly estimated. A similar behavior, with even larger variance, is shown by RE-IRL. The convergence speed remains very slow also for ε = 0.1, since ME-IRL does not guarantee that the recovered reward is a maximum of J. Instead, RE-IRL is able to produce a reward that reaches higher performance.
Besides the average return, we compare the recovered reward functions in terms of distance between the expert’s policy π
E
and the learned policy π
θ
(Kullback-Leibler divergence) estimated with:

Kullback-Leibler divergence between expert’s policy and learned policy in the Taxi problem as a function of the number of iterations of REINFORCE for model-free ECO-R.
We also test the model-based version of CR-IRL, where the transition model is estimated with (36). In Figs. 4 and 5 we notice that the usage of model-based ECO-R instead of model-free ECO-R has no relevant impact on CR-IRL and LPAL, while ME-IRL benefits from the model-based features only when the expert is not noisy.

Average return of the Taxi problem as a function of the number of iterations of REINFORCE for reward functions recovered from model-based ECO-Rs.

Kullback-Leibler divergence between expert’s policy and learned policy in the Taxi problem as a function of the number of iterations of REINFORCE for model-based ECO-R.
The previous experiments demonstrate that the set of ECO-R constructed by CR-IRL when coped with the trace heuristic criterion allows recovering policies that outperform popular IRL methods and display a faster learning curve w.r.t. the original reward function. The fact that ECO-Rs do not perform well with traditional IRL methods is simply explained. ECO-Rs are built exploiting a first-order optimality condition on the policy gradient with no need of a preselection of an approximation space; traditional IRL methods are designed to deal with handcrafted features that, in some intuitive sense, represent the underlying dynamics of the problem.
The trace heuristic can be also used when a given set of features (different from ECO-R) is provided. Since the usage of the Hessian makes sense only when all the considered features are a stationary point of the policy gradient we first need to remove the orthogonal projections over the space spanned by the gradient log-policy. We compare (Fig. 6) the learning performance of the set of the first 100 Proto-Value Functions (PVF) [30] when linearly combined with ME-IRL, LPAL and our trace heuristic. We notice that LPAL outperforms both the maximum entropy and the Hessian approaches regardless of the exploration level. Trace heuristic is slightly more effective w.r.t. maximum entropy when the expert is not noisy. The poor performance of trace heuristic with predefined approximation space is due to the fact that such space might not be sufficiently expressive to represent a sharp maximum of J.

Average return of the Taxi problem as a function of the number of iterations of REINFORCE with the reward function obtained from PVFs.
Overall, we notice that the two phases of CR-IRL (feature construction and reward recovery) are not fully independent because both share a strong relationship to the optimality conditions on the policy gradient and Hessian. In all scenarios, we considered the best performance is obtained with the combination of the two phases.
Sensitivity to the number of expert’s trajectories. The last set of experiments aims at evaluating the effect of the number of expert’s trajectories on the average return of the recovered reward functions (Figs. 7 and 8). The experiment is performed with model-free ECO-R. We notice that CR-IRL is susceptible to the number of expert’s trajectories only when ε = 0.1: the expert demonstrates a suboptimal behavior and this is more likely when the trajectories are many. This reflects on the estimation of the reward function that does not penalize suboptimal actions performed by the expert. LPAL shows the expected behavior, improving the average return as the number of trajectories increases. Also BC improves overall with the number of trajectories, more effectively when the expert is not noisy.

Average return of the Taxi problem as a function of the number of expert’s trajectories.

KL-divergence between expert’s policy and learned policy for the Taxi problem as a function of the number of expert’s trajectories.
9.3. Linear quadratic gaussian regulator
The Linear Quadratic Gaussian Regulator (LQG) [14] is a discrete time control problem in a continuous state-action space. The state and reward equations are given by:
We perform experiments in the one-dimensional case (n = 1, 1D-LQG), the values of the coefficients are reported in Table 1.
Coefficients of the 1D-LQG experiments
We compare CR-IRL with GIRL using two linear parametrizations of the reward function: \begin flalign*R(s,a,\omega ) = \omega_1 s^2 + \omega_2 a^2 (GIRL-square),\\ R(s,a,\omega ) = \omega_1|s| + \omega_2|a| (GIRL-abs-val). \end flalign*
Tables 2 and 3 show the values of the policy gradient and the policy Hessian computed for the different recovered reward functions. GIRL, by construction, yields the reward functions with the smallest gradient in absolute value. On the contrary, CR-IRL provides a reward function with larger gradient variance; this is justified by the fact that the Hessian is a large negative number making the policy parameter value a very unstable point for the expected return and so the gradient estimation noisier.
Policy gradient ∇ θ J (θ) of the recovered reward functions of 1D-LQG for different valuesof σ2 (± standard deviation)
Policy Hessian
In Fig. 9 the recovered reward functions are represented. We can see that GIRL-square is able to recover almost exactly the original reward (but it is very sensitive to the available expert’s trajectories), indeed the original reward function falls into the considered class of rewards. CR-IRL recovers rewards that penalize significantly the disadvantageous regions, this favors the learning speed as the experiments demonstrate. Clearly, as σ2 increases the penalized region reduces.

Representation of the recovered reward functions for 1D-LQG.
Learning speed experiments. The training is performed using REINFORCE [59] with Adam [26] (learning rate 0.002, other parameters with default value), at each iteration 100 trajectories are used to estimate the gradient and the initial parameter is k = -0.2. All data are averaged over 40 runs and the error bars correspond to the 95% confidence intervals.
Figure 10 shows the parameter value learned with REINFORCE using a Gaussian policy with two different variances. We notice that CR-IRL, fed with 20 expert’s trajectories, converges closer and faster to the expert’s parameter w.r.t. to the original reward, advantage function and GIRL with both parametrizations when σ2 = 0.01. Instead, the convergence value of CR-IRL when the expert is explorative σ2 = 1.0 deviates significantly from the optimal value. This however, does not affect the average return, as shown in Fig. 11. Indeed, when the variance is large the effect of the parameter k (the mean of the distribution) on the average return is less relevant.

Parameter value of 1D-LQG as a function of the number of iterations of REINFORCE.

Average return of 1D-LQG as a function of the number of iterations of REINFORCE.
Sensitivity to the number of expert’s trajectories. We investigate the effect of the number of expert’s demonstrations on the performance of the considered IRL algorithms. Fig. 12 reports the convergence parameter value and the average return for a variable number of expert’s trajectories. We notice that CR-IRL is less sensitive w.r.t. to GIRL since, even if few expert’s trajectories are provided, CR-IRL penalizes the regions that the expert did not visit, avoiding the agent to fall into low-reward regions.

Parameter and average return of 1D-LQG as a function of the number of expert’s trajectories.
Soft penalization. In order to extend the recovered reward function to unseen state-action pairs we adopt a 2NN model with a Gaussian kernel (bandwidth
Sensitivity to penalization and number of neighbors. We also investigate the effect of the number of neighbors in the extension of the recovered reward function on unvisited state-action pairs. Figure 13 shows the parameter value and the average return as a function of the number of iterations (the bandwidth of the Gaussian kernel are fixed to

Parameter value and average return of 1D-LQG as a function of the number of iterations of REINFORCE with a different number of neighbors.
Experiments with two-dimensional LQG. In order to compare the second-order criteria we discussed in Section 6, we perform a set of experiments with the two-dimensional LQG (2D-LQG). We consider two settings, as reported in Table 4. In the first case (a) the dynamics of the two states are fully independent, this is equivalent to considering two one-dimensional LQGs running in parallel. In the second case (b), instead, one state influences the other in a symmetric manner; as a consequence, the optimal controller matrix
Coefficients of the 2D-LQG experiments
We compare the maximum eigenvalue optimality criterion (ME-opt), the trace optimality criterion (TR-opt) and the trace heuristic (TR-heu). Tables 5 and 6 report the eigenvalues and the trace of the recovered reward functions for cases (a) and (b) respectively. In Fig. 14 the expected return is represented with its second order approximation as a paraboloid in canonical form:
Eigenvalues and trace of the policy Hessian for the recovered reward functions for the 2D-LQGcase (a) (± standard deviation)
Eigenvalues and trace of the policy Hessian for the recovered reward functions for the 2D-LQGcase (b) (± standard deviation)

Second order approximation of the expected return for the 2D-LQG.
From Fig. 14 we observe that for case (a) the recovered rewards display a similar shape. This is a consequence of the fact that the two dynamics are independent, therefore the directions of the eigenvectors are not affected one another. On the contrary in case (b), we observe some differences. The ME-opt criterion tends to recover rewards with isotropic shape: the eigenvalues (see Tables 5 and 6) are very close. The TR-opt and the TR-heu, which is its surrogate, tend to sharpen the curve in one direction as much as possible leaving the other direction almost flat.
In terms of learning speed, we observe in Fig. 15 that all the reward functions recovered by CR-IRL allow reaching closely the optimal parameter faster w.r.t. the original reward function. However, in case (a), it is visible that the original reward function converges closer to the optimal parameter. The three criteria, in case (a), do not display significant differences. On the contrary, in case (b), we observe that the reward function recovered by ME-opt displays a better performance w.r.t. the original reward function, converging closer and faster to the optimal parameter. The deviation from the optimal parameter, however, does not have a visible effect on the average return, since all curves in Fig. 16 are almost overlapping.

Parameter value for the 2D-LQG as a function of the number of iterations of REINFORCE.

Average return for the 2D-LQG as a function of the number of iterations of REINFORCE.
9.4. Car on the hill.
We further experiment CR-IRL in the continuous Car on the Hill domain [15]. The environment considers a car modeled by a point mass that is traveling on a hill. The action a acts directly on the acceleration of the car. The original formulation assumes to have only two extreme values (full acceleration (a = 4) or full deceleration (a = -4)), but for our convenience, we admit the full range a ∈ [-4, 4]. The control problem objective is roughly to bring the car in a minimum time to the top of the hill while preventing the position p of the car to become smaller than -1 and its speed v to go outside the interval [-3, 3]. Therefore, the state space is continuous of dimension two (the position p and the speed v of the car). If pt+1 and vt+1 are such that |pt+1|>1 or |vt+1|>3 then a terminal state is reached. The reward function R (p, v, a) is defined through the following expression:
We approximate the optimal deterministic policy
We exploit N = 20 expert’s trajectories to estimate the parameters
Figure 17 shows the original reward function and the reward functions recovered by CR-IRL for the different values of ε. The original reward function displays three regions associated to the reward values +1, 0 and -1. However, most of the +1 region is never reached resulting in penalization when considering the reward functions recovered by CR-IRL. Those functions assign non-zero reward only to the region to which the original reward would assign 0 and to the absorbing state reached as the car gets to the top of the hill with sufficiently small speed. At first glance, the reward functions recovered by CR-IRL are significantly different w.r.t. the original reward and seem not to be informative. Nevertheless, the empirical evaluation demonstrates that they allow computing the optimal policy.

Representation of the recovered reward functions for Car on the Hill.
Learning speed experiments. This experiment is intended to show that the reward function recovered by CR-IRL does not necessarily need to be used with policy gradient approaches. We compare the average return as a function of the number of iterations of FQI, fed with the different recovered rewards.
Figure 18 shows that FQI converges faster to the optimal policy when coped with the reward recovered by CR-IRL rather than with the original reward, regardless of the exploration level ε. When the expert is deterministic (ε = 0), BC reaches the expert’s performance, since the considered class of parametric policies is sufficiently expressive to represent the optimal deterministic policy. Also CR-IRL reaches the expert’s performance in one iteration only.

Average return of Car On Hill problem as a function of FQI iterations varying the value of exploration ε.
BC however is not resilient to noise, displaying a significant performance degradation as ε increases. CR-IRL, on the other hand, is able to recover the optimal policy quickly even in the case of explorative experts.
In Fig. 19 we compare the trajectories of the expert’s policy, the maximum likelihood policy (BC) and the policy computed via FQI from the reward recovered by CR-IRL. We can see that when the expert is deterministic the trajectories are almost overlapping. On the contrary, when the exploration rate ε increases we can see that some expert’s trajectories fail to reach the profitable absorbing state. This is a consequence of the fact that a random action is taken with probability ε. BC is almost always able to get the final +1 reward but not optimally in terms of the number of decision epochs required. Finally, CR-IRL, even if trained with a noisy expert, recovers a reward function that induces a policy which is near-optimal, as all trajectories get to the +1 final reward in almost the minimum number of steps.

Trajectories of the expert’s policy, the ML policy and the policy computed via FQI from the reward recovered by CR-IRL for different values of ε.
A key step towards enforcing the scalability of IRL to real-world domains is the availability of an algorithm able to construct reward functions requiring just a set of expert’s trajectories. Most of the contributions of this work point to that direction. We presented CR-IRL that mixes BC and IRL in order to construct the features and single out a reward function. BC represents a preliminary step, necessary in order to extract the set of ECO-Q making the gradient vanish. It is worth noting that, for our algorithm, the choice of the policy model is less constraining w.r.t. pure behavioral cloning. Nevertheless, this represents a delicate aspect of CR-IRL, as a poor approximation would make the algorithm extract a suboptimal set of ECO-Q. The main theoretical contributions of this paper lie in the notion of policy rank and in the finite-sample analysis of the feature extraction phase. We think that the informativity of a parametric policy is an appealing notion that, together with Theorem 1, can be used also outside the area of IRL and particularized for specific classes of policies. Once the ECO-Q have been extracted, we proposed two methods to construct the set of ECO-R. Clearly, we focused on the model-free approach that exploits reward shaping in order to build the space of advantage functions. This choice, of course, causes the reduction of the space dimensionality that prevents CR-IRL from considering certain classes of rewards. Nevertheless, using the advantage function as reward function is beneficial for almost all RL algorithms. Finally, we introduced several second-order approaches to select a reward function in the constructed space. The multi-objective interpretation offers a unifying view of the problem, that we particularized for specific choices of optimality criteria, ending in a heuristic that provides good empirical results.
We showed that CR-IRL is able to recover reward functions that can be used to learn optimal policies (in terms of expected return) but at a faster learning rate w.r.t. the original reward function of the problem. Moreover, even though CR-IRL exploits BC to get a parametric representation of the expert’s policy, the policies learned with the reward function recovered by CR-IRL significantly outperform BC. We think this is a key strength of our algorithm, resulting from merging BC and IRL. BC brings to CR-IRL the ability to avoid low-reward regions that the expert has never visited, while IRL, producing a reward representation, allows overcoming the limit of the fixed policy model. Furthermore, CR-IRL outperforms several popular IRL methods designed to recover a reward function as a linear combination of given features, when fed with the set of ECO-R. On the other hand, the performance of the trace heuristic when CR-IRL is fed with automatically generated features, such as Proto-Value Functions, is somehow unsatisfactory. This is a consequence of the fact that the two phases of CR-IRL, feature construction and reward recovery, both originate from conditions on the policy gradient and Hessian and therefore are not independent. The second-order optimality criteria make sense only when the policy gradient is null and take into account only the regions of the environment visited by the expert.
Numerous questions remain open. We believe there is space for further research in this topic, mainly directed towards theoretical and experimental settings. We outline in the followings the main research lines.
Theoretical analysis of the maximum likelihood policy
CR-IRL, as already seen, requires to estimate a parametric representation of the expert’s policy from the available trajectories. This is a critical point since it requires the choice of a policy model. Although the estimated policy is not used to collect samples, its accuracy might affect the construction of the ECO-Q space and, as a result, the recovered reward function. We have identified two sources of error. First, the maximum likelihood estimation is based on the expert’s trajectories, few trajectories lead to poor approximation even if the expert’s policy falls into the chosen policy space. Second, when the expert’s policy cannot be represented by the policy space, how does the distance between the expert’s policy and the maximum likelihood policy affect the reward construction? In particular, it would be interesting deriving a bound relating the performance gap and the policy distance and study how this error propagates in the policy gradient and for the construction of the set of ECO-Q and ECO-R. We partially answered this question in Section 7.
Scalability and error propagation
Our approach requires a two-step procedure to build the approximation space for the reward function. As a consequence, this might introduce scalability issues when considering complex environments or large datasets. Indeed, CR-IRL requires to perform two SVDs: one to extract the set of ECO-Q and another for orthogonalizing the set of ECO-R. Furthermore, this contributes to the propagation of the error introduced in the maximum likelihood estimation of the expert’s policy. In order to overcome this limitation, we could resort to trajectory-based formulations of the policy gradient, like (11), in which the reward function appears in place of the Q-function. These equations can be used to build directly the set of ECO-R with no need to pass through the approximation space of the Q-function.
Reward transferability
The issue of reward transferability is substantial in any real-world application of IRL. This problem has been addressed in a few works and only for simple problems, such as the grid world and the simulated highway driving. In this paper, we have not evaluated the transferability properties of the reward functions recovered by CR-IRL. Intuitively, CR-IRL penalizes deviations from the expert’s policy thus the recovered reward drives the learning process towards the expert’s behavior. Thus it seems that no transferability is enforced by CR-IRL as the agent will tend to reproduce the expert’s policy. Clearly, IRL methods that exploit handcrafted features, encoding implicitly similarities between states and actions, are more suitable to enforce transferability. Nevertheless, if we consider very explorative experts, yielding trajectories in which almost all states and actions are visited, CR-IRL would assign a non-penalized reward even to suboptimal trajectories, producing a more transferable reward.
Appendix
A. Matrix notation for finite Markov decisionprocesses
In this appendix, we report the conventions we adopted for the matrix representation of the finite MDPs. The transition model P is represented as a
The distribution of the initial state is represented by a stochastic vector
Footnotes
In discounted problems (γ < 1) we can define an “intrinsic horizon”, induced by the discount factor, as
We want to stress that our primal objective is to recover the reward function since we aim to explain the motivations that guide the expert and, possibly, to transfer it, not just to replicate the behavior. As explained in the introduction, we aim to exploit the synergy between BC and IRL.
Notice that any linear combination of the ECO-Qs also satisfies the first-order optimality condition.
The inner product, as defined, is clearly symmetric, positive definite and linear, but there could be state-action pairs never visited, i.e.,
For a more detailed view of the matrix notation for MDPs refer to Appendix A.
A normalization condition is necessary since the magnitude of the trace of a matrix can be arbitrarily changed by multiplying the matrix by a constant.
This assumption does not allow to consider deterministic policies as G would be infinite. Nevertheless, it is typically used for the analysis of policy gradient methods [60].
Parameter distance is not always a good metric, in particular in presence of parameters that do not affect the policy performance. We will use it for the LQG case only.
We made the choice to use ε-Boltzmann instead of Boltzmann policy since we can leverage on ε to control the exploration-exploitation trade off explicitly.
The maximum eigenvalue optimality criterion is not suitable for this case due to the presence of blocked-to-zero eigenvalues.
When using linear feature models for the policy, zero initialization does not prevent learning, differently from the case of deep neural networks.
