{'fraction_non_alphanumeric': 0.0427797282857579, 'fraction_numerical': 0.010723553655930392, 'mean_word_length': 4.34795918367347, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Learning Navigation Costs from Demonstration in Partially Observable Environments

This paper focuses on inverse reinforcement learning (IRL) to enable safe and efficient autonomous navigation in unknown partially observable environments. The objective is to infer a cost function that explains expert-demonstrated navigation behavior while relying only on the observations and state-control trajectory used by the expert. We develop a cost function representation composed of two parts: a probabilistic occupancy encoder, with recurrent dependence on the observation sequence, and a cost encoder, defined over the occupancy features. The representation parameters are optimized by differentiating the error between demonstrated controls and a control policy computed from the cost encoder. Such differentiation is typically computed by dynamic programming through the value function over the whole state space. We observe that this is inefficient in large partially observable environments because most states are unexplored. Instead, we rely on a closed-form subgradient of the cost-to-go obtained only over a subset of promising states via an efficient motion-planning algorithm such as A* or RRT. Our experiments show that our model exceeds the accuracy of baseline IRL algorithms in robot navigation tasks, while substantially improving the efficiency of training and test-time inference.


I. INTRODUCTION
Practical applications of autonomous robot systems increasingly require operation in unstructured, partially observed, unknown, and changing environments. Achieving safe and robust navigation in such conditions is directly coupled with the quality of the environment representation and the cost function specifying desirable robot behavior. Designing a cost function that accurately encodes safety, liveness, and efficiency requirements of navigation tasks is a major challenge. In contrast, it is significantly easier to obtain demonstrations of desirable behavior. The field of inverse reinforcement learning [1]- [3] (IRL) provides numerous tools for learning cost functions from expert demonstration.
We consider the problem of safe navigation from partial observations in unknown environments. We assume that demonstrations containing expert poses, controls, and sensory observations over time are available. The objective is to infer the cost function, which depends on the observation sequence, and explains the demonstrated behavior. This inference can only be done indirectly by comparing the control inputs, that a robot may take based on its current cost representation, to the expert's actions in that situation.
Learning a cost function requires a differentiable control policy with respect to the stage cost parameters. Computing such derivatives has been addressed by several successful approaches [4]- [7]. Ratliff et al. [4] developed algorithms Our main contribution lies in a non-stationary cost representation, combining a probabilistic occupancy map encoder, with recurrent dependence on observations z1:t, and a cost encoder, defined over the occupancy features. We also perform efficient (in the size of the state-space) forward non-stationary policy computation and efficient (closed-form subgradient) backpropagation. The bottom-right plot illustrates that motion planning may be used to update and differentiate cost-to-go estimates only in promising areas of the state space rather than using full Bellman backups, which is particularly redundant in partially observable environments. with regret bounds for computing subgradients of planning algorithms (e.g., A* [8], RRT [9], [10], etc.) with respect to the cost features. Ziebart et al. [5] developed a dynamic programming algorithm for computing the expected state visitation frequency of a policy extracted from expert demonstrations to enforce that it earns the same reward as the demonstrated policy. Tamar et al. [6] showed that the value iteration algorithm could be approximated using a series of convolution (computing value function expectation over stochastic transitions) and maxpooling (choosing the best action) allowing automatic differentiation. Okada et al. [7] proposed path integral networks in which the control sequence resulting from path integral control may be differentiated with respect to the controller parameters. All of these works, however, assume a known environment and only optimize the parameters of a cost function defined over it.
A series of recent works [11]- [16] address IRL under partial observability. Wulfmeier et al. [13] train deep neural network representations for Ziebart et al.'s Maximum Entropy IRL [5] method and consider streaming lidar scan observations of the environment. Karkus et al. [16] formulate the IRL problem as a POMDP [17], including the robot pose and environment map in the state. Since a naïve representation of the occupancy distribution may require exponential memory in the map size, the authors assume partial knowledge of the environment (the structure of a building is known but the furniture placement is not). A control policy is obtained via the SARSOP [18] algorithm,  [16] works with uncertainty only on the robot or furniture location, while the main environment structure is known.
which approximates the cost-to-go function only over an optimally reachable space. Gupta et al. [14] address visual navigation in partially observed environments while using hierarchical VIN as the planner. Khan et al. [19] introduce a memory module to VIN to address partial observability.
Many IRL algorithms rely on dynamic programming, including VIN and derivatives [14], [19], which requires updating cost-to-go estimates over all possible states. Our insight is that in partially observable environments, the costto-go estimates need to be updated and differentiated only over a subset of states. Inspired by [4], we obtain cost-to-go estimates only over promising states using a motion planning algorithm. This helps to obtain a closed-form subgradient of the cost-to-go with respect to the learned cost function from the optimal trajectory. While Ratiff et al. [4] exploit this observation in fully observable environments, none of the works focusing on partial observability take advantage of this. Our work differs from closely related works in Table I. In summary, we offer two contributions illustrated in Fig. 1: Firstly, we develop a non-stationary cost function representation composed of a probabilistic occupancy map encoder, with recurrent dependence on the observation sequence, and a cost encoder, defined over the occupancy features (Sec. III). Secondly, we optimize the cost parameters using a closedform subgradient of the cost-to-go obtained only over a subset of promising states (Sec. IV).

II. PROBLEM FORMULATION
Consider a robot navigating in an unknown environment with the task of reaching a goal state x g ∈ X . Let x t ∈ X be the robot state, capturing its pose, twist, etc., at discrete time t. For a given control input u t ∈ U where U is assumed finite, the robot state evolves according to known deterministic dynamics: x t+1 = f (x t , u t ). Let m * : X → {−1, 1} be a function specifying the true occupancy of the environment by labeling states as either feasible (−1) or infeasible (1) and let M be the space of possible environment realizations m * . Let c * : X × U × M → R ≥0 be a cost function specifying desirable robot behavior in a given environment, e.g., according to an expert user or an optimal design. We assume that the robot does not have access to either the true occupancy map m * or the true cost function c * . However, the robot is able to make observations z t ∈ Z (e.g., using a lidar scanner or a depth camera) of the environment in its vicinity, whose distribution depends on the robot state x t and the environment m * . Given a training set D := (x t,n , u * t,n , z t,n , x g,n ) Cost encoder expert trajectories with length T n to demonstrate desirable behavior, our goal is to • learn a cost function estimate c t : X × U × Z t × Θ → R ≥0 that depends on an observation sequence z 1:t from the true latent environment and is parameterized by θ, • derive a stochastic policy π t from c t such that the robot behavior under π t matches the prior experience D. To balance exploration in partially observable environments with exploitation of promising controls, we specify π t as a Boltzmann policy [3], [20] associated with the cost c t : where the optimal cost-to-go function Q * t is: Problem. Given demonstrations D, optimize the cost function parameters θ so that log-likelihood of the demonstrated controls u * t,n is maximized under the robot policies π t,n : Tn t=1 log π t,n (u * t,n |x t,n ; z 1:t , θ). (3) The problem setup is illustrated in Fig. 1. While Eqn. (2) is a standard deterministic shortest path (DSP) problem, the challenge is to make it differentiable with respect to θ. This is needed to propagate the loss in (3) back through the DSP problem to update the cost parameters θ. Once the parameters are optimized, the robot can generalize to navigation tasks in new partially observable environments by evaluating the cost c t based on the observations z 1:t iteratively and (re)computing the associated policy π t .

III. COST FUNCTION REPRESENTATION
We propose a cost function representation comprised of two components: a map encoder and a cost encoder.
The map encoder incrementally updates a hidden state h t using the most recent observation z t obtained from robot state x t . For example, a Bayes filter with likelihood function parameterized by ψ can convert the sequential input (x 1:t , z 1:t ) into a fixed-sized hidden state h t+1 : The cost encoder uses the latent environment map h t to define the cost function estimate c t (x, u) at a given state-control pair (x, u). A convolutional neural network (CNN) [21] with parameters φ can extract cost features from the environment map: This conceptual model, combining recurrent estimation of a hidden environment state, followed by feature extraction to define the cost at (x, u) is illustrated in Fig. 2. The model is differentiable by design, allowing its parameters θ = {ψ, φ} to be optimized. We propose an instantiation of this general model, specific to modeling occupancy costs from depth measurements in robot navigation tasks.

A. Map Encoder
We encode the occupancy probability of different environment areas into a hidden state h t . In detail, we discretize X into N cells and let m * ∈ {−1, 1} N be the vector of true occupancy values over the cells. Since m * is unknown to the robot, we maintain the occupancy likelihood P(m * = 1|x 1:t , z 1:t ) given the history of states x 1:t and observations z 1:t . See Fig. 3 for an example of a depth measurement z t and associated occupancy likelihood over the map m * . The representation complexity may be simplified significantly if one assumes independence among the map cells m * j : We use inspiration from occupancy grid mapping [22], [23] to design recurrent updates for the occupancy probability of each cell m * j . Since m * j is binary, its likelihood update can be simplified by defining the log-odds ratio of occupancy: The recurrent Bayesian update of h t,j is: where the increment is a log-odds observation model. The occupancy posterior can be recovered from the occupancy log-odds ratio h t,j via a sigmoid function: The sigmoid function satisfies the following properties: To complete the recurrent occupancy model design, we parameterize the log-odds observation model: where Bayes rule was used to represent it in terms of an inverse observation model g j (x, z) and a prior occupancy log-odds ratio h 0,j , whose value may depend on the environment (e.g., h 0,j = 0 specifies a uniform prior over occupied and free cells). Note that map cells m * j outside of the sensor field of view at time t are not affected by z t , in which case g j (x t , z t ) = h 0,j . Now, consider a cell m * j along the direction of the k-th sensor ray, whose depth measurement is z t,k . Let d(x t , m * j ) be the distance between the robot position and the center of mass of cell m * j . We model the occupancy likelihood of m * j as a truncated sigmoid around the true distance d(x t , m * j ): where ψ k is a learnable parameter, δz t,k := d(x t , m * j )−z t,k , and is a distance threshold on the influence of the k-th sensor ray on the occupancy of cells around the point of reflection. Using (10), this implies the following log-odds inverse sensor model for cells m * j along the k-th sensor ray: This model suggests that one may also use a more expressive multi-layer neural network in place of the linear transformation ψ k δz t,k of the distance differential along the k-th ray: In summary, the map encoder starts with prior occupancy log-odds h 0 , updates them recurrently via: where the log-odds inverse sensor model g j (x t , z t ; ψ k ) is specified for the j-th cell along the k-th ray in (14), and provides the cell occupancy likelihood in (9) as output.

B. Cost Encoder
Given a state-control pair (x, u), the cost encoder uses the output σ (h t ) of the map encoder to obtain a cost function estimate c t (x, u). A complex interacting structure over the feature representation σ (h t ) can be obtained via a deep neural network with parameters φ. Wulfmeier et al. [13] proposed several CNN architectures, including pooling and residual connections of fully convolutional networks, to model c t (x, u) from σ (h t ). While complex architecture may provide better performance in practice, we also develop a simpler model for comparison using the inductive bias of obstacle avoidance in robot navigation.
Let s and l be a small and large positive parameter, respectively. The cost of applying control u in robot state x can be modeled as large when the transition f (x, u) encounters an obstacle and as small otherwise: Since m * is unknown, we use the estimated occupancy probabilities σ (h t ) to compute the expectation of c(x, u) over m * : where h t [x] is the entry of the map encoder state that corresponds to the environment cell containing x. This simple cost encoder has parameters φ := [s, l] T and its output c t (x, u) is differentiable with respect to φ and ψ through σ (h t ).

IV. COST LEARNING VIA DIFFERENTIABLE PLANNING
We focus on optimizing the parameters θ of the cost representation c t (x, u; z 1:t , θ) developed in Sec. III. Since the true cost c * is not directly observable, we need to differentiate the loss function L(θ) in (3), which, in turn, requires differentiating through the DSP problem in (2) with respect to the cost function estimate c t .
Value Iteration Networks (VIN) [6] shows that T iterations of the value iteration algorithm can be approximated by a neural network with T convolutional and minpooling layers. This allows VIN to be differentiable with respect to the stage cost. While VIN can be modified to operate with a finite horizon and produce a non-stationary policy, it would still be based on full Bellman backups (convolutions and minpooling) over the entire state space. As a result, VIN scales poorly with the state-space size, while it might not even be necessary to determine the optimal cost-to-go Q * t (x, u) at every state x ∈ X and control u ∈ U in the case of partially observable environments.
Instead of using dynamic programming to solve the DSP (2), any motion planning algorithm (e.g., A* [8], RRT [9], [10], etc.) that returns the optimal cost-to-go Q * t (x, u) over a subset of the state-control space provides an accurate enough solution. For example, a backwards A* search applied to problem (2) with start state x g , goal state x ∈ X , and predecessors expansions according to the motion model f provides an upper bound to the optimal cost-to-go: u)) ∀f (x, u) ∈ CLOSED, where g are the values computed by A* for expanded nodes in the CLOSED list and visited nodes in the OPEN list. Thus, a Boltzmann policy π t (u | x) can be defined using the gvalues returned by A* for all x ∈ CLOSED∪OPEN ⊆ X and a uniform distribution over U for all other states x. A* would significantly improves the efficiency of VIN [6] or other full backup Dynamic Programming variants by performing local Bellman backups on promising states (the CLOSED list).
In addition to improving the efficiency of the forward computation of Q * t (x, u), using a planning algorithm to solve (2) is also more efficient in back-propagating errors with respect to θ. In detail, using the subgradient method [4], [24] to optimize L(θ) leads to a closed-form (sub)gradient of Q * t (x t , u t ) with respect to c t (x, u), removing the need for back-propagation through multiple convolutional or minpooling layers. We proceed by rewriting Q * t (x t , u t ) in a form that makes its subgradient with respect to c t (x, u) obvious. Let T (x t , u t ) be the set of feasible state-control trajectories τ := x t , u t , x t+1 , u t+1 , . . . , x T −1 , u T −1 starting at x t , u t and satisfying x k+1 = f (x k , u k ) for k = t, . . . , T − 1 with x g = x T . Let τ * ∈ T (x t , u t ) be an optimal trajectory corresponding to the optimal cost-to-go function Q * t (x t , u t ) of a deterministic shortest path problem, i.e., the controls in τ * satisfy the additional constraint With these definitions, we can view the optimal cost-to-go function Q * t (x t , u t ) as minimum over T (x t , u t ) of the inner product of the cost function c t and the visitation function µ τ : where X can be assumed finite because both T and U are finite. This form allows us to (sub)differentiate Q * t (x t , u t ) with respect to c t (x, u) for any x ∈ X , u ∈ U.
Lemma 1. Let f (x, y) be differentiable and convex in x.
Then, ∇ x f (x, y * ), where y * := arg min y f (x, y), is a subgradient of the piecewise-differentiable convex function g(x) := min y f (x, y).
Applying Lemma 1 to (17) leads to the following subgradient of the optimal cost-to-go function: which can be obtained from the optimal trajectory τ * corresponding to Q * t (x t , u t ). This result and the chain rule allow us to obtain the complete (sub)gradient of L(θ).
where the first term has a closed-form, while the second term is available from (18) and the cost representation in Sec. III: The computation graph structure implied by Prop. 1 is illustrated in Fig. 1. The graph consists of a cost representation layer and a differentiable planning layer, allowing end-to-end minimization of L(θ) via stochastic (sub)gradient descent. Full algorithms for the training and testing phases (Fig. 1) are shown in Alg. 1 and Alg. 2.
Although the form of the gradient in Prop. 1 is similar to that in Ziebart et al. [5], our contributions are orthogonal. Our contribution is to obtain a non-stationary cost-to-go function and its (sub)gradient for a finite-horizon problem using forward and backward computations that scale efficiently with the size of the state space. On the other hand, the results of Ziebart et al. [5] provide a stationary cost-to-go function and its gradient for an infinite horizon problem. The maximum entropy formulation of the stationary policy is a well grounded property of using a soft version of the Bellman update, which can explicitly model the suboptimality of expert trajectories. However, we can show the benefits of our approach without including the maximum entropy formulation and will leave it as future work.
V. EXPERIMENTS We evaluate our approach in 2D grid world navigation tasks at two scales. Obstacle configurations are generated randomly in maps m * n of sizes 16 × 16 or 100 × 100. We use an 8-connected grid so that a control u t causes a transition x t+1 = f (x t , u t ) from x t to one of the eight neighbor cells x t+1 . At each step, the robot receives a 360 • lidar scan z t at 5 • resolution, resulting in 72 beams z t,k in each scan (see 16 × 16 100 × 100 Train  7638  514k  970  460k  Validation  966  66k  122  58k  Test  952  -122  -TABLE II: Dataset size. We sample 10 trajectories in each map in training and validation, and each sample takes the form (x1:t,n, u * t,n , z1:t,n, xg,n). In testing, the robot's task is to navigate from one randomly sampled start to goal location on each map. Fig. 3). The lidar range readings are corrupted by an additive zero mean Gaussian noise. The standard deviation of the noise is 0.05 and 0.2 (grid cell = 1) and the lidar maximum range is 2.5 and 10 in 16 × 16 and 100 × 100 domains, respectively. Note that the lidar range is smaller than the map size to demonstrate environment partial observability. During test time, the domain size is the maximum size allowed for the observed area along a trajectory. Demonstrations are obtained by running an A* planning algorithm to solve the deterministic shortest path problem on the true map m * n . The number of maps and training samples generated are shown in Table II.

A. Baseline and model variations
We use DeepMaxEnt [13] as a baseline and compare it to three variants of our model. In all variants, we parameterize an inverse observation model and use the log-odds update rule in Eqn. (13) as the map encoder. This map encoder is sufficiently expressive to model occupancy probability from lidar observations in a 2D enviroment. The A* algorithm is used to solve the DSP (2), providing the optimal cost-to-go Q * t (x, u) for x ∈ CLOSED ∪ OPEN and a subgradient of Q * t (x t , u t ) according to (18). All the neural networks are implemented in the PyTorch library [25] and trained with the Adam optimizer [26] until convergence.
DeepMaxEnt uses a neural network to learn a cost function directly from lidar observations without explicitly having a map representation. The neural network in our experiments is the "Standard FCN" in [13] in the 16 × 16 domain, and the encoder-decoder architecture in [27] in the 100×100 domain. Value iteration is approximated by a finite number of Bellman backup iterations, equal to the map size. The experiments in the original DeepMaxEnt paper [13] use the mean and variance of the height of the 3D lidar points in each cell, as well as a binary indicator of cell visibility, as input features to the neural network. Since our synthetic experiments are set up in 2D, the count of lidar beams in each cell is used as replacement of the height mean and variance. This is a fair adaptation because Wulfmeier et. al. [13] argued that obstacles generally represent areas of larger height variance which means more beam counts in our observations.
Ours-HCE stands for hard-coded cost encoder. This simple variant of our model uses Eqn. (16) with s = 1 and l = 100 set explicitly as constants.
Ours-SCE stands for soft-coded cost encoder and has s and l in Eqn (16) as learnable parameters.
Ours-CNN is our most generic variant using a convolutional neural network as cost encoder. The network architecture is the same as in DeepMaxEnt for fair comparison.  in grayscale is in the background. The optimal cost-to-go estimate g from A* is shown in a blue-yellow colormap in the foreground (brighter means higher cost-to-go). The optimal trajectories τ * in cyan corresponding to Q * t (xt, ut) are obtained during A* planning for subgradient computation in Eqn. (18). The last figure shows the final successful trajectory in green and an optimal shortest path in the fully observable enviroment in blue. Both Ours-HCE and Ours-SCE explicitly incorporate cell traversability through the cost design in (16). Test results show that this explicit cost encoder is successful at obstacle avoidance, regardless of whether the parameters s, l are constants in Ours-HCE or learnable in Ours-SCE. The performance of Ours-HCE also shows that the map encoder is learning a correct map representation from the noisy lidar observations since the only trainable parameters are ψ in the inverse observation model (13). However, both models fail at matching demonstrations in validation because the cost encoder (16) emphasizes obstacle avoidance explicitly, leaving little capacity to learn from demonstrations. Ours-CNN combines the strength of learning from demonstrations and generalization to new navigation tasks while avoiding obstacles. Its validation results are on par with DeepMaxEnt, showing the validity of the closed-form subgradient in (18). Ours-CNN significantly outperforms DeepMaxEnt in new tasks at test time. The performance gap of DeepMaxEnt in the two domains shows that a general CNN architecture applied directly to the lidar scan measurements is not as effective as the map encoder in Ours-CNN at modeling occupancy probability. Fig 5 shows the map occupancy estimation, as well as the optimal trajectories necessary for subgradient computation in Sec IV.

B. Experiments and
b) Robustness to noise: The robustness of Ours-CNN to the observation noise is evaluated in the 16 × 16 domain. c) Computational efficiency: Finally, we compare the efficiency of a forward pass through our A* planner and the value iteration algorithm in DeepMaxEnt. The A* algorithm in our models is implemented in C++ and evaluated on a CPU. The VI algorithm is implemented using convolutional and minpooling layers in Pytorch as described in [6] and is evaluated on a GPU. We record the time that each models takes to return a policy π t given a cost function c t . Our A* algorithm takes only 0.02 ms as compared to VI's 0.2 ms on the 16 × 16 map. In the 100 × 100 domain, our A* algorithm takes 0.6 ms, compared to VI's 14 ms, illustrating the scalability of our model in the size of the state space.

VI. CONCLUSION
We proposed an inverse reinforcement learning approach for infering navigation costs from demonstration in partially observable enviroments. Our model introduces a new cost representation composed of a probabilistic occupancy encoder and a cost encoder defined over the occupancy features. We showed that a motion planning algorithm can compute optimal cost-to-go values over the cost representation, while the cost-to-go (sub)gradient may be obtained in closed-form. Our work offers a promising model for encoding occupancy features in navigation tasks and may enable efficient online learning in challenging operational conditions.