AAAI 2023

State-Conditioned Adversarial Subgoal Generation

Vivienne Huiling Wang1Joni Pajarinen2Tinghuai Wang3Joni-Kristian Kämäräinen1
1Tampere University2Aalto University3Huawei Helsinki Research Center
TL;DR  SAGA trains the high-level policy of a hierarchical agent as the generator of an adversarial game. A state-conditioned discriminator separates its subgoals from relabeled subgoals, which the current low-level policy is known to reach, so the subgoals the high level proposes stay compatible with the low-level policy as it changes.

Overview

Hierarchical reinforcement learning decides at two time scales: a high-level policy proposes subgoals, and a low-level policy turns each subgoal into actions. When both levels learn off-policy, the high level faces a moving target. The low-level policy keeps changing, so the outcome of a subgoal stored in the replay buffer no longer reflects what the current low-level policy would do. Relabeling corrects the stored experience, yet the high-level policy can still propose subgoals that the low-level policy cannot reach.

SAGA addresses this with adversarial learning. Relabeled subgoals serve as examples of subgoals the current low-level policy reaches. A discriminator conditioned on the state learns to tell them apart from the subgoals generated by the high-level policy, and the high-level policy learns to make its subgoals indistinguishable from them. On Ant Maze, Ant Gather, Ant Push and Ant Fall, this improves both learning efficiency and final performance over the compared hierarchical methods.

?

The problem

Off-policy hierarchical learning is non-stationary: the same subgoal from the same state leads to different outcomes as the low-level policy learns, and the high level keeps proposing subgoals the low level cannot reach.

✓

A reachable reference

Relabeled subgoals explain what the current low-level policy actually did, so they show which subgoals it can reach from each state.

⇄

An adversarial game

The high-level policy is the generator; a discriminator conditioned on the state separates generated from relabeled subgoals, and the high level learns to fool it.

Explainer video

The method in five minutes

A narrated walk-through of the problem, the idea and the mechanism, with data from an agent trained by the released code.

Method

Subgoals the current low-level policy can reach

Four steps: the two-level framework, the non-stationarity that relabeling repairs, the adversarial game between the high-level policy and a discriminator, and the reason the discriminator looks at the state.

1  The two-level framework

Every steps, the high-level policy observes the state and proposes a subgoal : a desired change of the robot's position. It is rewarded with the environment reward collected over the next steps,

In between, the low-level policy chooses the primitive actions . Its reward is the negative distance to the subgoal, which is carried along as the robot moves so that it keeps pointing at the same place:

Both levels are trained concurrently and off-policy with TD3. In the paper, SAGA is built on HRAC as the base hierarchical model.

goal start g High-level policy πh every k steps: state → subgoal g Low-level policy πl every step: (state, g) → action a state s subgoal g action a reward: environment reward summed over the k steps reward: −‖s + g − s′‖, the remaining distance to the subgoal
Two-level execution in the U-shaped Ant maze. The high-level policy acts once every k steps; the low-level policy acts at every step to reach the current subgoal.

2  Non-stationarity, and what relabeling repairs

A high-level transition stores the state , the subgoal , the summed reward and the state reached steps later. That outcome was produced by the low-level policy of the time the transition was collected. Once the low-level policy has changed, the same subgoal from the same state leads elsewhere, so old high-level transitions describe a low-level policy that no longer exists. This makes off-policy training of the high level non-stationary.

Relabeling repairs the stored transitions. The stored subgoal is replaced by the subgoal under which the current low-level policy best explains the recorded low-level actions. For a deterministic low-level policy with Gaussian action noise, the log-likelihood reduces to a squared action error:

The maximum is taken over a few candidates: the stored subgoal, the displacement achieved over the steps, and samples around it. Relabel a recorded transition in the demo →

25k100k400k1Mend of the k steps, by training steps of the low-level policy
The same state and the same subgoal, executed for k steps by the low-level policy of one training run at four stages (released code, U-shaped Ant maze). The outcome stored with a subgoal depends on when it was collected.

3  Adversarial subgoal generation

Relabeling changes what the high-level policy learns from, not what it proposes. The policy can still propose subgoals that the current low-level policy cannot reach, such as a point behind a wall or one too far away for steps. Such incompatible subgoals distort the high-level value function and hurt exploration.

Relabeled subgoals are the opposite: they explain what the current low-level policy actually did, so they are reachable by construction. Under stationary data they are assumed to approximate the subgoals of an optimal high-level policy, and a growing gap between generated and relabeled subgoals signals non-stationarity.

SAGA closes this gap with adversarial learning. The high-level policy is the generator . A discriminator outputs the probability that the subgoal is a relabeled subgoal for the state rather than one generated by the high-level policy. The two play the minimax game

where is the high-level replay buffer with relabeled subgoals. The discriminator learns to separate the two kinds of subgoals; the high-level policy learns to make its subgoals indistinguishable from relabeled ones.

High-level replay buffer (s, g, reward, s′) and the k recorded low-level actions Relabel with the current low-level policy (s, g̃) State s sampled from the same buffer High-level policy generator G(s) (s, G(s)) Discriminator D(g | s) probability that g is a relabeled subgoal for s D learns: relabeled → 1 D learns: generated → 0 G learns to fool D (weight α) High-level critic Qh G also maximizes Qh
Off-policy adversarial learning of the high-level policy. Relabeled subgoals (green) and generated subgoals (gold) are judged at the same states. The high-level policy maximizes its critic and, with weight αadv, fools the discriminator.

4  Why the discriminator looks at the state

Whether a subgoal can be reached depends on where the robot is. Next to a wall, the subgoals behind it are out of reach; in an open corridor, many more are within reach. The discriminator and the generator are therefore both conditioned on the state, so the adversarial signal depends on where a subgoal is proposed. Move the robot in the demo →

where subgoals really leaddiscriminator D(g | s)robot next to the inner wallwhere subgoals really leaddiscriminator D(g | s)robot in the open corridor
The same two robot positions in two views. Left of each pair: where subgoals really lead from that position (simulated, final stage of the run). Right: the discriminator’s D(g | s) at the same position, with the generated subgoal (gold star).

5  The objective of the high-level policy

The high-level policy maximizes its value through the deterministic policy gradient of TD3,

and is updated with the combined gradient of the value and the adversarial term:

The weight balances the two terms. Larger values speed up learning but can slow down the learning of the value function, and very small values reduce the method to its base model; the paper uses on all tasks.

Training

All parts are trained concurrently, with TD3 at both levels and Adam for every network:

  • Low-level policy: updated on its intrinsic reward, the negative distance to the subgoal.
  • High-level critic: updated on high-level transitions whose subgoals are relabeled with the current low-level policy.
  • Discriminator: updated on relabeled subgoals (real) and generated subgoals (fake) at the same states.
  • High-level policy: updated with the combined gradient of its value and the adversarial term.

Settings in the paper: TD3 at both levels; actor and critic networks with three fully connected layers of width 300 and ReLU; a discriminator with layers of 300, 300 and 1 units, LeakyReLU (slope 0.2) and a sigmoid output; Adam for all networks; αadv = 0.001.

Interactive demo

The method, computed live

One training run of the released code on the U-shaped Ant maze, from 25k to 1M steps. The robot’s motion comes from real simulations of the Ant that were recorded in advance, since the physics does not run in the browser; the high-level policy, the discriminator and the low-level policy are evaluated live in your browser from their exported weights.

Results reported in the paper

Higher success, and subgoals the low level can reach

Ant Maze with dense and sparse reward and with top-down image observations, Ant Gather, Ant Push and Ant Fall; 5M environment steps; 10 seeds.

Final performance

Ant MazeAnt Maze SparseAnt GatherAnt PushAnt FallAnt Maze (Image)
SAGA0.93 ± 0.010.92 ± 0.012.72 ± 0.070.72 ± 0.020.47 ± 0.020.87 ± 0.02
HRAC0.83 ± 0.030.75 ± 0.082.19 ± 0.340.06 ± 0.060.11 ± 0.070.76 ± 0.03
HIRO0.54 ± 0.060.29 ± 0.100.02 ± 0.020.00 ± 0.000.01 ± 0.010.53 ± 0.06
LESSON0.81 ± 0.04––0.62 ± 0.020.38 ± 0.010.74 ± 0.06
TD30.0 ± 0.00.01 ± 0.00.0 ± 0.00.0 ± 0.00.0 ± 0.0–

Success rate (Ant Gather: episode reward) after 5M steps, mean ± standard error over 10 seeds.

Ablations

Ant MazeAnt Maze SparseAnt GatherAnt PushAnt Fall
SAGA0.93 ± 0.010.92 ± 0.012.72 ± 0.070.72 ± 0.020.47 ± 0.02
w/o state for D0.91 ± 0.020.88 ± 0.012.62 ± 0.060.58 ± 0.030.39 ± 0.03
w/o state for D/G0.0 ± 0.00.19 ± 0.010.0 ± 0.00.0 ± 0.00.0 ± 0.0
SAGA-HIRO0.58 ± 0.030.72 ± 0.040.18 ± 0.150.0 ± 0.00.11 ± 0.07

w/o state for D: the discriminator is not conditioned on the state. w/o state for D/G: neither network is conditioned on the state; the generator maps random noise to subgoals and no longer acts as the high-level actor. SAGA-HIRO: the same adversarial learning on HIRO as the base model, instead of HRAC.

Generated subgoals lie close to the reached positions

Ant MazeAnt Maze SparseAnt GatherAnt PushAnt Fall
SAGA2.79 ± 0.082.13 ± 0.261.65 ± 0.522.62 ± 0.462.49 ± 0.23
HRAC3.41 ± 0.314.38 ± 0.843.59 ± 0.914.95 ± 1.114.10 ± 1.03
HIRO10.74 ± 1.0514.14 ± 0.013.71 ± 1.159.38 ± 2.8511.4 ± 1.69

Distance between the generated subgoal and the position reached at the end of the k-step low-level rollout, mean ± standard error over 10 seeds.

Citation

BibTeX

@inproceedings{wang2023saga,
  title={State-Conditioned Adversarial Subgoal Generation},
  author={Vivienne Huiling Wang and
          Joni Pajarinen and
          Tinghuai Wang and
          Joni{-}Kristian K{\"{a}}m{\"{a}}r{\"{a}}inen},
  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
  volume={37},
  number={8},
  pages={10184--10191},
  year={2023},
  doi={10.1609/aaai.v37i8.26213}
}