---
title: Robust Maximum Entropy Behavior Cloning
url: https://www.emergentmind.com/topics/robust-maximum-entropy-behavior-cloning-rm-ent
type: topic
---

# Robust Maximum Entropy Behavior Cloning

Robust Maximum Entropy Behavior Cloning (RM-ENT) is a framework for imitation learning (IL) that enables robust policy learning from a set of demonstrations, some of which may be adversarial or noisy. By exploiting a min–max entropy-based objective and adaptive demonstration weights, RM-ENT automatically detects and suppresses uninformative or misleading demonstrations without requiring a simulator or additional environment interactions. The approach introduces a general saddle-point optimization scheme with feature-matching constraints to induce maximum-entropy distributions over actions, achieving strong sample efficiency and robustness to corrupted data [2101.01251].

## 1. Formal Optimization Framework

RM-ENT builds upon the principle of maximum entropy imitation learning, augmenting it with an adversarial-aware weighting mechanism on demonstrations. Given a set of $D$ demonstrations $\mathcal{D} = \{d=1,\dots,D\}$, each induces an empirical state-action distribution $\tilde p(s,a|d)$. The learner aims to find a stochastic policy $\pi(a|s)$ and a set of weights $w = (w_1, \dots, w_D)$, with $w_d \in [0,1]$, $\sum_d w_d = M$ (where $M$ is the estimated number of trustworthy demonstrations).

The primary objective is a min–max (saddle-point) formulation:
\[
\min_{w\in\mathbb{R}^{D}}\,\max_\pi\Bigl\{-\sum_{s,a} \tilde p_w(s)\,\pi(a|s)\,\log\pi(a|s)\Bigr\}
\]
subject to:
- Weighted feature matching:
\[
\sum_{d=1}^{D} w_d \sum_{s,a} \tilde p(s,a|d) [\pi(a|s) - \tilde\pi(a|s,d)] f_i(s,a) = 0 \qquad \forall\, i=1,\dots,n
\]
- Policy normalization: $\sum_a \pi(a|s) = 1$ for all $s$
- Demo weight constraints: $0 \leq w_d \leq 1$, $\sum_d w_d = M$

Expressed in dual form over Lagrange multipliers $\lambda \in \mathbb{R}^n$, the policy takes the Gibbs form:
\[
\pi_\lambda(a|s) = \frac{1}{z_\lambda(s)} \exp\left(\sum_{i=1}^n \lambda_i f_i(s,a)\right)
\]
where $z_\lambda(s) = \sum_{a\in\mathcal{A}} \exp\left(\sum_{i=1}^n \lambda_i f_i(s,a)\right)$. The optimization is over the joint dual-primal objective:
\[
\min_{\lambda, w} -\frac{1}{M} \sum_{d=1}^D w_d \left[ -\sum_{s} \tilde p(s|d) \log z_\lambda(s) + \sum_{s,a} \tilde p(s,a|d) \sum_{i=1}^n \lambda_i f_i(s,a)\right]
\]
with linear constraints on $w$. The resulting problem is non-convex in $(\lambda, w)$ and is solved using sequential quadratic programming (SQP) [2101.01251].

## 2. Entropy-Based Demo Weight Mechanism and Adversarial Detection

A core feature of RM-ENT is the assignment of adaptive weights $w_d$ to demonstrations, governing their influence on policy induction. Each demonstration contributes a scalar
\[
c_d(\lambda) = b_d(\lambda) - a_d(\lambda),
\]
where:
\[
a_d(\lambda) = \sum_s \tilde p(s|d)\,\log z_\lambda(s), \qquad b_d(\lambda) = \sum_{s,a} \tilde p(s,a|d)\,\sum_{i} \lambda_i f_i(s,a).
\]
The min-over-$w$ step in the optimization suppresses weights on demonstrations that would force excessive entropy, as adversarial or stochastic data increases the entropy cost. A demonstration $d$ with low or negative $c_d(\lambda)$ is downweighted, with $w_d \rightarrow 0$ for strongly adversarial cases.

Optimization over $w$ at each step corresponds to solving a linear or quadratic program:
\[
\min_w -\sum_d w_d c_d(\lambda) \qquad \text{s.t.} \; \sum_d w_d = M,\, 0 \leq w_d \leq 1.
\]
This automated filtering suppresses adversarial or random demonstrations while retaining the influence of correct ones, enabling robust imitation learning.

## 3. Algorithmic Structure and Computational Outline

RM-ENT alternates between updating Lagrange multipliers $\lambda$ for the dual (policy) variables and re-optimizing demonstration weights $w$ given the current policy. A high-level outline:

```text
Input: set of demos D, estimated # trusted demos M, features {f_i(s,a)}, tolerance ε
Initialize λ ← 0, w ← uniform (M/D)
repeat
    1. Build partition function z_λ(s) = ∑_a exp(∑_i λ_i f_i(s,a))
    2. Set policy π(a|s) = exp(∑_i λ_i f_i(s,a)) / z_λ(s)
    3. For each demo d: compute a_d, b_d, c_d = b_d - a_d
    4. Solve QP: minimize −∑_d w_d c_d  s.t. ∑_d w_d = M, 0 ≤ w_d ≤ 1
    5. Gradient update λ
    6. Check convergence in (λ, w)
until convergence
Output: π(a|s), w_d for each d
```

No environment simulator or rollouts are required after receiving the input demonstrations. The per-iteration computational cost scales favorably with the number of demonstrations $D$ (practical for $D \lesssim 100$) [2101.01251].

## 4. Theoretical Properties and Convergence

For any fixed set of weights $w$, the maximization in $\pi$ is strictly convex, yielding a unique maximum-entropy “Gibbs” policy $\pi_\lambda$. The minimization over $w$ for any fixed $\lambda$ is linear. The non-convexity of the joint problem in $(\lambda, w)$ precludes global optimality guarantees; the SQP-based optimization converges only to local Karush–Kuhn–Tucker (KKT) points under standard smoothness and constraint qualifications. As a result, only local convergence is certified, mirroring limitations of established alternating-optimization or EM-style procedures in related imitation learning frameworks [2101.01251].

## 5. Empirical Performance and Experimental Protocol

Empirical validation encompasses both tabular and control-suite tasks:

- **Gridworld (5x5):** Synthetic experiments with mixtures of correct, adversarial, and random demonstrations. Examples:
    - Two correct demos: $w=(0.5, 0.5)$, 100% path-accuracy.
    - Two correct + 1 adversarial: $w=(0.5, 0.5, 0)$, 83% accuracy.
    - Two correct + three random: $w=(0.5, 0.5, 0, 0, 0)$, 92% accuracy.

- **OpenAI Gym (MountainCar, Acrobot):** Discrete-action, continuous-state domains. Baselines include supervised behavioral cloning (BC), maximum-entropy IRL with TRPO (“FEM”), and Game-Theoretic Apprenticeship Learning (GTAL).
    - When no adversarial data, RM-ENT performance matches BC (100% performance).
    - With one or more adversarial demonstrations, RM-ENT preserves high returns by suppressing their weights, whereas BC and IRL baselines degrade linearly with contamination.
    - Performance degrades only when adversarial demos outnumber experts, at which point RM-ENT collapses to random performance.
    - Computation time: RM-ENT converges in $<$ 10 seconds; IRL baselines take several minutes due to repeated simulator queries [2101.01251].

| Setting            | RM-ENT Weighting | Accuracy/Return   | BC/IRL Baseline |
|--------------------|------------------|-------------------|-----------------|
| 2 correct demos    | $(0.5, 0.5)$     | 100%              | 100%            |
| 2 correct, 1 adv   | $(0.5, 0.5, 0)$  | 83%               | $<$83%          |
| 2 correct, 3 rand  | $(0.5, 0.5, 0, 0, 0)$ | 92%         | $<$92%          |
| Gym: adv $>$ expert| collapse         | random-like       | random-like     |

## 6. Practical Considerations and Limitations

- **Sample complexity:** RM-ENT requires zero environment interactions beyond provided demonstrations. In contrast, IRL baselines (e.g., TRPO-based) require hundreds of thousands of simulator steps.
- **Computational efficiency:** Each iteration involves:
    1. State-action pass for $z_\lambda(s)$ (partition function)
    2. Per-demo $c_d$ computation
    3. QP solve in $D$ variables
    4. SQP-style $\lambda$ update.
    For $D \lesssim 100$ demos, overall runtime is in seconds.
- **Characteristic constraints and limitations:**
    1. Only local optima are guaranteed due to joint non-convexity.
    2. Discriminative feature design is required: features $f_i$ must distinguish correct from adversarial demonstrations.
    3. Algorithm supports discrete actions only; continuous-action extensions remain an open direction.
    4. The number of “trusted” demonstrations $M$ must be estimated, typically via cross-validation.

A plausible implication is that, while robust to adversarial data and highly sample efficient, the framework's performance hinges on feature selection and the accuracy of $M$. In summary, RM-ENT extends maximum-entropy behavior cloning with adaptive demo weighting, enabling policy learning that is robust to corrupted demonstrations and efficient in sample and computation, without reliance on simulators [2101.01251].

Source: https://www.emergentmind.com/topics/robust-maximum-entropy-behavior-cloning-rm-ent