TL;DR
Adversarial inverse reinforcement learning (AIRL) learns a reward function from an expert's demonstrations. It trains a discriminator to tell expert state-action pairs from the learner's, then uses that discriminator's output as the reward for a standard reinforcement learning step. Its reward is built so that it depends on the state more than on the particular dynamics, which lets a policy trained on it still behave well after the environment changes.
Builds on: Inverse Reinforcement Learning, Generative Adversarial Network, Maximum Entropy Reinforcement Learning, Reward Shaping · Leads to: reward-learning methods that transfer across environments, a step beyond plain Behavior Cloning
Where it's used
Robot control from demonstrations. A robot arm or a legged robot can be shown how to move by a person, but writing a reward function that scores a whole motion is hard. AIRL learns that score from the demonstrations, then reinforcement learning turns it into a policy.
Reusing a reward on a changed body. The paper's transfer test trains a quadruped "ant" to run forward, then disables and shrinks two of its front legs. A policy optimised with the learned state-only reward has to change its gait to crawl, and it still works, where a policy transferred from GAIL does not. The paper reports a score of 130.3 for that policy, against negative 58.8 for a policy transferred the GAIL way.
Benchmark imitation tasks. On Pendulum, Ant, Swimmer and HalfCheetah, the paper gives the learner 50 expert demonstrations and compares AIRL with GAIL, the leading imitation method of its time. Both reach close to the best achievable results on these tasks, so AIRL matches imitation performance while also recovering a reward.
How it works
Think of a learner that must move the way an expert moves. AIRL runs a loop with two players, the same pattern as a generative adversarial network.
- Collect expert pairs. Record state-action pairs from expert demonstrations. Check: each pair is one moment of expert behaviour, so the expert data is a set of such pairs.
- Collect learner pairs. Let the current policy act in the environment, a Markov decision process, and record its own state-action pairs. Check: the learner's pairs are the fake samples in the adversarial game.
- Score each pair with the discriminator. For a pair the discriminator outputs , the probability that the pair came from the expert, not the learner. It is built from a learned function and the learner's own probability . Check: when is high relative to , is near 1, meaning "looks like the expert".
- Update the discriminator. Adjust so that expert pairs get near 1 and learner pairs get near 0. Check: is the reward candidate, so this is also a reward update.
- Read off the reward. The policy's reward for a pair is , which is the log-odds that the pair came from the expert. Check: pairs the discriminator trusts earn high reward.
- Update the policy. Run a Policy Gradient step on that reward, using a method such as Trust Region Policy Optimization (TRPO). The policy moves toward expert-like pairs. Check: the learner's new pairs should look more like the expert's, so the next discriminator step has a harder job.
- Repeat. Alternate steps 3 to 6 until the discriminator cannot separate the two sets of pairs. Then the learned is the reward the expert seems to be optimising.
The difference from ordinary imitation is step 5. A plain imitation method uses the discriminator only to nudge the policy toward the expert. AIRL keeps as a reward, and step 4 tunes that reward against the expert data.
The math
Step 3 in symbols: the discriminator
Let be the learner's policy and a learned function. The discriminator is
It is the probability that came from the expert, under equal prior odds. The function is always positive, so always lies between 0 and 1.
Step 4 in symbols: the training objective
The discriminator is trained by ordinary binary cross-entropy: expert pairs are labelled 1 and learner pairs 0. Expert pairs push up, learner pairs push down. Because depends on only through , minimising this loss adjusts directly.
Step 5 in symbols: the reward
Solve the formula above for the odds. Since , taking logs gives
The policy's reward is this log-odds. The paper uses the opposite sign convention for its written objective, but the quantity that rewards expert-like pairs is this one.
What the optimum looks like
At the optimum the learner matches the expert, and the paper shows that . For a maximum-entropy optimal policy, , which is the Advantage Function. So for a plain imitation objective, is the advantage of the expert's policy. That reward is valid in the training environment, but it is entangled with the dynamics.
The disentangled form
To remove that entanglement, the paper writes as a state-only reward plus a shaping term:
Here is the reward estimate, is a learned shaping term, is the discount factor, and is the next state. The term is the form of Reward Shaping that leaves the optimal policy unchanged. Under the paper's conditions, the optimum gives and , where is the true reward. The shaping term absorbs the value function, so is left as the true state reward.
Worked examples
- Take one state-action pair with the learner's probability .
- Suppose the learned function is , so .
- The discriminator is .
- The reward is .
- Check: , the same number.
- Interpretation: the discriminator says the pair looks 80 percent expert-like, and the reward is positive, so the policy is pushed toward this action.
- In a state with two actions, let the expert's policy be and .
- At the optimum, , so and .
- Suppose the learner's policy has also converged, so .
- For , . For , .
- Interpretation: the discriminator outputs one half everywhere. It cannot tell the expert from the learner, which is the sign that the learner has matched the expert.
The comparison uses the paper's Table 1, Ant-Disabled column, with 5 runs per entry.
- The policy transferred from GAIL, with no reward learned, scores negative 58.8.
- The policy optimised with AIRL's state-only reward scores 130.3.
- The gap is points.
- The policy trained with the true reward on the disabled ant scores 315.5, so the AIRL policy reaches of that.
- Interpretation: the learned reward carries over to a changed body, while copying the expert's actions does not.
Try it: on the Point Mass-Maze column, the AIRL state-only policy scores negative 8.82 and the policy trained on the true reward scores negative 8.45. What is the gap between the two scores? Answer: points, so the learned reward is close to the true one on this task.
Common mistakes and tradeoffs
It is tempting to think AIRL is just GAIL with a different name. In fact, GAIL trains a discriminator only to shape the policy, so it does not return a reward. AIRL keeps the discriminator's as a reward, which is why it can be reused in a new environment.
It is tempting to think a learned reward is automatically the true reward. In fact, many rewards explain the same expert, and shaping terms can change the reward without changing the optimal policy. That is why AIRL uses a state-only reward and a shaping term, and why the disentangled form is needed for transfer.
It is tempting to think the discriminator's output is a probability of success. In fact is a probability that a pair came from the expert, and at the optimum it sits at one half, so a value near 0.5 means the learner is doing well, not badly.
Use AIRL when you need a reward you can reuse or inspect, when the environment may change, or when you have demonstrations but no reward. Do not use it when a simple behaviour-cloning baseline already works and no transfer is needed, since adversarial training is slower and less stable. Alternatives include GAIL when you only need a policy, and direct behaviour cloning on large expert datasets.
History
Inverse reinforcement learning was framed by Ng and Russell in 2000 as the problem of finding a reward that explains expert behaviour. Its ambiguity was a known difficulty: many rewards can explain the same policy. Ziebart and colleagues developed maximum-entropy inverse reinforcement learning, which chooses among the candidate rewards by a principle. AIRL builds on that framework.
Finn and colleagues showed in 2016 a connection between generative adversarial networks and inverse reinforcement learning, with a discriminator over whole trajectories. Ho and Ermon (2016) then introduced GAIL, which drops the reward structure to make imitation fast but cannot recover a reward. Fu, Luo and Levine (2017) gave AIRL: a state-action discriminator with the reward structure that recovers a reward, and a state-only form that transfers across environments. The paper's results on transfer and benchmark imitation tasks are the evidence cited for it.
Recap
- Inverse reinforcement learning asks for the reward that explains expert behaviour, which is ambiguous without extra structure.
- AIRL uses a discriminator to separate expert pairs from learner pairs.
- The policy's reward is , the log-odds of expert-likeness; at the optimum equals the expert's log-policy, which is the advantage.
- A state-only reward plus a shaping term removes dynamics-dependent parts, so the reward transfers to changed environments.
- Read next: Inverse Reinforcement Learning for the wider problem, and Generative Adversarial Network for the adversarial training loop.
Check yourself
QuestionWhat is the discriminator's output D(s, a) a probability of, and what does D equal when the learner matches the expert?Show answer
QuestionA pair has learner probability pi(a | s) = 0.5 and learned function f(s, a) = log 2. What is the discriminator D, and what is the policy's reward?Show answer
QuestionWhy does AIRL use a state-only reward with a shaping term instead of the plain state-action reward f(s, a)?Show answer
QuestionA team records 50 expert demonstrations of a warehouse robot and wants a reward it can reuse after the robot's wheels are replaced with a different model. Should they use AIRL or plain behaviour cloning, and why?Show answer
Sources
- Fu, J., Luo, K. and Levine, S. (2017). Learning Robust Rewards with Adversarial Inverse Reinforcement Learning. arXiv:1710.11248. https://arxiv.org/abs/1710.11248
- Wikipedia, "Inverse reinforcement learning". https://en.wikipedia.org/wiki/Inverse_reinforcement_learning