Adversarial Inverse RL (AIRL)
AIRL copies the goal instead of the motions. It splits what the expert wanted from how the old world moved, so the aim still works when the world changes.
Why Does This Exist?
Copying motions fails when the world shifts. GAIL matches the expert's state-action visits, and its discriminator soaks up the training world's physics along with the behavior. Move one hurdle, change the friction, jam a motor, and the copied motions land in empty air. The agent learned how to move, not what to want.
Wanting is a reward function, and recovering rewards from demonstrations is inverse RL. Classical maximum entropy IRL does this honestly and slowly: every gradient step re-solves a forward RL problem, which is hopeless for hard continuous control.
AIRL keeps the adversarial sample efficiency and repairs the transfer. It structures the discriminator so the portable state reward separates from the dynamics-dependent shaping term. The reward exports to new physics. The shaping stays behind.
Think of It Like This
The agility dog that learns the prize
A champion dog runs an agility course: tunnel, red hurdle, finish line with food.
The mimicking student memorizes paw placements and leap timing. While the hurdles stay put, it shines. Slide the red hurdle three meters left and it leaps into empty air. It copied the route, not the reason.
The AIRL student splits the demo in two. The hurdle jump was local maneuvering for that arena layout. The food at the finish was the point. In a new arena it plans a fresh path around the moved hurdles and still sprints to the bowl.
Where it stops: a real dog smells the food. AIRL gets zero reward signal during demos and must isolate the goal purely from the discriminator math, which is why the state-only restriction below carries the whole guarantee.
How It Actually Works
Symbols for this page: is the state, the action, the next state, the learner policy, the portable state reward network, the shaping potential network, the discount, and the discriminator.
Maximum entropy IRL says the expert policy looks like . AIRL bakes that shape into the discriminator:
Reward split that survives new physics
Reward shaping theory says two rewards share the optimal policy exactly when they differ by . AIRL parameterizes the advantage to expose that split:
The term sees only the state and carries the goal. The term absorbs layout quirks and value offsets. When stays state-only, theory says its optimum equals the true reward up to a constant, free of transition dynamics. That is the export license: train in world one, carry into world two, re-plan there.
The two-step training loop
The discriminator learns binary cross-entropy on expert transitions against policy transitions. The policy trains with policy gradients on the surrogate reward:
Low policy probability under the current raises the surrogate, which pushes the policy toward expert-like transitions without ever copying joint angles directly.
Worked example with discriminator 0.9813
One transition carries , potentials and , discount , and policy probability .
Shaped advantage:
The portable part contributes and the shaping contributes . Discriminator:
Near one, so the discriminator calls this expert-like. Surrogate reward with :
Now change the world. Higher friction routes the same to with . The shaping becomes and the advantage drops to . The portable does not move. The agent re-optimizes under the new physics instead of replaying stale motions.
Code
A short check of the worked numbers above, with type hints throughout:
import math
def shaped_advantage(g: float, h: float, h_next: float, gamma: float) -> float: return g + gamma * h_next - h
def discriminator(f: float, pi: float) -> float: expf = math.exp(f) return expf / (expf + pi)
g = 2.0h = 1.0h_next = 1.5gamma = 0.9pi = 0.20
f = shaped_advantage(g, h, h_next, gamma)d = discriminator(f, pi)r = f - math.log(pi)print([round(f, 2), round(math.exp(f), 4), round(d, 4), round(r, 4)])# -> [2.35, 10.4856, 0.9813, 3.9594]
f2 = shaped_advantage(g, h, 0.80, gamma)print([round(f2, 2), round(g, 2)])# -> [1.72, 2.0]# -> expected output:[2.35, 10.4856, 0.9813, 3.9594][1.72, 2.0]Watch Out For
Letting the reward see the action
Widening to feels more expressive and breaks the guarantee. With actions inside, the shaping term can no longer absorb dynamics uniquely, and the learned reward entangles with the training world's transitions. Transfer to new friction or payloads then produces erratic policies that exploit stale shaping.
Keep state-only. That single restriction is what makes the recovered reward portable.
The Quick Version
- AIRL structures its discriminator as with .
- The state-only carries the goal and exports across dynamics, while absorbs training-world shaping.
- Unlike GAIL motion matching, the recovered goal re-plans under new physics instead of replaying stale paths.
- One worked step gives advantage , discriminator and surrogate reward , with unchanged when shaping drops the total to .
- Conditioning the reward on actions voids the disentanglement, so keep state-only.