Relativistic Objectives

Dive into Deep Learning · §16.3

Relativistic Objectives and Pairwise Ranking
Bradley–Terry pairing critic · shift invariance · product-measure JS divergence · information bounds · fixed vs. random pairing landscapes

From Absolute Thresholds to Pairwise Ranking

Motivation

A single-sample discriminator scores each observation x against a fixed zero threshold (D(x) \gtrless 0), whereas pairwise preference models, such as Bradley–Terry reward models in RLHF, predict which of two candidates is better from their score difference:

  • Threshold fragility under score shifts: Adding a constant b to all critic scores flips single-sample threshold verdicts against 0, even though the relative ordering of real and generated samples has not changed.
  • Relativistic pairing (RpGAN; Jolicoeur-Martineau, 2019): Pairs a real sample x \sim p with a generated sample x' \sim q and predicts which member is real from their difference D(x) - D(x').
  • Three core questions: (1) Does the optimal ranker still estimate \lambda(x) = \log(p(x)/q(x))? (2) What divergence does it measure? (3) When does pairwise ranking prevent mode collapse?

The Bradley–Terry Pairing Objective (RpGAN)

Formulation & Implementation

Given an independent pair (x, x') with x \sim p and x' \sim q, the relativistic pairing objective models the probability that x outranks x' via the Bradley–Terry likelihood \sigma(D(x) - D(x')):

\Phi(D) = \mathbb{E}_{x \sim p,\; x' \sim q}\Big[\log \sigma\big(D(x) - D(x')\big)\Big]

  • The critic maximizes \Phi(D) (minimizes -\Phi(D) = \mathbb{E}[\operatorname{softplus}(D(x') - D(x))] over aligned minibatch pairs (x_i, x'_i)), while the practical non-saturating generator loss rpgan_loss_G swaps the arguments:
def rpgan_loss_D(critic, real, fake):
    """Relativistic pairing critic loss -E[log sigma(D(x) - D(x'))]."""
    return F.softplus(critic(fake) - critic(real)).mean()


def rpgan_loss_G(critic, real, fake):
    """Non-saturating pairing loss for the generator."""
    return F.softplus(critic(real) - critic(fake)).mean()

Shift Invariance and the Optimal Pairing Critic

Optimality Theorem

\frac{\delta \Phi}{\delta D(t)} = 0 \quad \Longleftrightarrow \quad D^\star(x) = \log \frac{p(x)}{q(x)} + c = \lambda(x) + c

  • Shift invariance: For any constant b \in \mathbb{R}, \Phi(D + b) = \Phi(D). The sign of an individual score D(x') is arbitrary; monitor the pairwise ranking accuracy P(D(x) > D(x')).
  • Unique optimal ranker: Because \log \sigma is strictly concave, setting the functional derivative \delta \Phi / \delta D(t) to zero identifies D^\star(x) = \lambda(x) + c uniquely up to an additive shift c.

Worked Example: Pairwise Ranking on Two States

Concrete Calculation

Consider a two-state space \{0, 1\} with p = (0.8, 0.2) and q = (0.2, 0.8). Compare the product distribution P = p \otimes q (real sample first) against Q = q \otimes p (real sample second):

Ordered Pair (a_1, a_2) (0, 0) (Tied) (1, 1) (Tied) (0, 1) (Mixed) (1, 0) (Mixed)
P = p \otimes q (real first) 0.16 0.16 0.64 0.04
Q = q \otimes p (real second) 0.16 0.16 0.04 0.64
  • Tied pairs (0, 0) and (1, 1) carry zero ordering information, while mixed pair (0, 1) identifies the real element with posterior probability \frac{0.64}{0.64 + 0.04} = \frac{16}{17} \approx 94.1\% (vs. 80\% from a single sample).
  • At D^\star(0) - D^\star(1) = \lambda(0) - \lambda(1) = \log 16, the gain \sup_D \Phi(D) + \log 2 \approx 0.319 nats equals \mathrm{JS}(P, Q) (1.66\times larger than \mathrm{JS}(p, q) \approx 0.193 nats):
JS(p, q) = 0.193   JS(P, Q) = 0.319   sup Phi + log 2 = 0.319

Lifting to Product Space: Why Differences Suffice

The Lifting Lemma

\log \frac{dP}{dQ}(a_1, a_2) = \log \frac{p(a_1)\,q(a_2)}{q(a_1)\,p(a_2)} = \lambda(a_1) - \lambda(a_2)

  • Product-space log-loss game: View an ordered pair (a_1, a_2) as a single draw from P = p \otimes q (real first) vs. Q = q \otimes p (real second).
  • Zero restriction gap: Because the unconstrained pair maximizer \mathcal{D}^\star(a_1, a_2) = \lambda(a_1) - \lambda(a_2) already has difference form, restricting critics to \mathcal{D}(a_1, a_2) = D(a_1) - D(a_2) achieves the exact supremum V_{P,Q} = 2\,\Phi(D).

Theorem: The Calibrated Pairing Divergence

Product-Space Jensen–Shannon

d_{\mathrm{Rp}}(p, q) := \sup_D \Phi(D) + \log 2 = \mathrm{JS}\big(p \otimes q,\; q \otimes p\big)

  • Entropy and explicit expectation forms: Equals H(\frac{1}{2}(p \otimes q + q \otimes p)) - H(p) - H(q) = \log 2 - \mathbb{E}_{p,q}[\log(1 + \frac{q(x)p(x')}{p(x)q(x')})].
  • Mutual-information interpretation: For a randomly ordered pair (a_1, a_2) with ordering label y \in \{0, 1\}, d_{\mathrm{Rp}}(p, q) = I((a_1, a_2); y) is the information the pair carries about which member is real.

Information Bounds: Comparing d_Rp and JS

Chain Rule of Mutual Information

d_{\mathrm{Rp}}(p, q) = I(a_1; y) + I(a_2; y \mid a_1) = 2\,\mathrm{JS}(p, q) - I(a_1; a_2)

  • Near equilibrium (q \to p): Redundancy I(a_1; a_2) = \Theta(\|p - q\|^4) vanishes faster than \mathrm{JS}(p, q) = \Theta(\|p - q\|^2), so d_{\mathrm{Rp}}(p, q) \approx 2\,\mathrm{JS}(p, q).
  • General sandwich bound: \mathrm{JS}(p, q) \le d_{\mathrm{Rp}}(p, q) \le \min(2\,\mathrm{JS}(p, q), \log 2), still saturating at \log 2 on disjoint supports.

The Relativistic Rank Weight in Generator Updates

Per-Sample Gradient Weighting

\nabla_\theta \Phi = -\mathbb{E}_z\Big[w_{\textrm{Rp}}(G_\theta(z))\,\nabla_\theta D(G_\theta(z))\Big], \quad w_{\textrm{Rp}}(x') = \mathbb{E}_{x \sim p}\Big[\sigma\big(D(x') - D(x)\big)\Big]

  • Saturating vs. non-saturating rank weight: w_{\textrm{Rp}}(x') is the expected win probability of x' against real data x \sim p; rpgan_loss_G uses 1 - w_{\textrm{Rp}}(x') = \mathbb{E}_p[\sigma(D(x) - D(x'))] \approx 1 when D(x') \ll D(x).
  • Shift-invariant comparison: Compares D(x') against the live distribution of real scores D(x) rather than a fixed zero threshold.

Discrete Mode-Coverage Landscapes: Three Objectives

Sun, Fang, and Schwing Analysis

\mathcal{E}_{\mathrm{diag}} = \sup_D \frac{1}{n}\sum_{i=1}^n \log\sigma\big(D(x_i) - D(x'_i)\big), \qquad \mathcal{E}_{\mathrm{all}} = \sup_D \frac{1}{n^2}\sum_{i,j=1}^n \log\sigma\big(D(x_i) - D(x'_j)\big)

  • Three coupling regimes: \mathcal{E}_{\mathrm{GAN}} = \mathrm{JS}(\hat{p}, \hat{q}) - \log 2 (single-sample), \mathcal{E}_{\mathrm{diag}} (permanent 1-to-1 coupling x_i \leftrightarrow x'_i), and \mathcal{E}_{\mathrm{all}} = d_{\mathrm{Rp}}(\hat{p}, \hat{q}) - \log 2 (all n^2 pairs).
  • Collisions (n^n - n! configurations): Every x'_i sits on a real point \{x_1, \ldots, x_n\} but at least two coincide, leaving a real mode uncovered.

Stepping Off a Collision: Fixed vs. All-Pairs

Cycle Rule on Directed Graphs

Under fixed pairing \mathcal{E}_{\mathrm{diag}}, draw a directed arrow from each real index i to the position of its paired generated point x'_i. Around any directed cycle, score differences \sum (D(x_i) - D(x'_i)) = 0 cancel, so concavity of \log\sigma forces tied scores (-\log 2 per cycle edge); on acyclic arrows, D(x_i) - D(x'_i) \to +\infty achieves 0:

gen         classical, all pairs, paired: nats, multiples of log 2
[0, 0]      [-0.477 -0.347 -0.347]  [-0.69 -0.5  -0.5 ]
[0, 0.1]    [-0.347 -0.173 -0.347]  [-0.5  -0.25 -0.5 ]
  • When both generated points collide on x_1 ([0, 0]) and x'_2 steps off toward x_2 ([0, 0.1]), both \mathcal{E}_{\mathrm{GAN}} and \mathcal{E}_{\mathrm{all}} strictly increase (from -0.477 and -0.347 to -0.347 and -0.173), trapping x'_2 at the collision.
  • Under fixed pairing \mathcal{E}_{\mathrm{diag}}, the self-loop 1 \to 1 stays tied at -\log 2 while the acyclic edge 2 \to x'_2 stays at 0, so the loss remains completely flat at -0.5\log 2 \approx -0.347 all the way to x_2.

Enumerating Suboptimal Collision Minima

Fixed Coupling vs. Minibatch Re-Pairing

Counting, over all assignments in \{0, \ldots, n-1\}^n (n = 2, 3), the collisions that are strict local minima:

def small_moves(gen):
    """Each generated point stays or steps to one of n fresh positions next to it."""
    n = len(gen)
    for steps in itertools.product(range(n + 1), repeat=n):
        if any(steps):
            yield [g + k / 10 if k else g for g, k in zip(gen, steps)]

def count_bad_minima(n):
    """Suboptimal strict local minima among the assignments, per loss."""
    best, count = losses(list(range(n))), np.zeros(3, dtype=int)
    for gen in itertools.product(range(n), repeat=n):
        value = losses(list(gen))
        rises = np.all([losses(m) > value + 1e-9 for m in small_moves(list(gen))],
                       axis=0)
        count += rises & (value > best + 1e-9)
    return count
n = 2: classical 2, all pairs 2, paired 0;  n^n - n! = 2
n = 3: classical 21, all pairs 21, paired 0;  n^n - n! = 21

Why Minibatch Training Faces All-Pairs Collisions

Practical Pitfall

  • What Sun et al. (2020) proved: The fixed one-to-one coupling objective \mathcal{E}_{\mathrm{diag}} has 0 suboptimal collision local minima (0 vs. n^n - n!), because any colliding point x'_i not on a directed cycle can move toward x_i along a flat plateau.
  • What happens under minibatch re-pairing: Drawing fresh independent minibatches from p and q at every step averages over random pairings, evaluating the all-pairs expectation \mathcal{E}_{\mathrm{all}} = d_{\mathrm{Rp}}(\hat{p}, \hat{q}) - \log 2 (which retains all n^n - n! collision minima).
  • Takeaway: In §16.4, our 2 \times 2 experiment on 25 Gaussians confirms that R_1 + R_2 gradient penalties, rather than pairing alone, drive mode coverage.

Saturating vs. Non-Saturating Pairing Near Data

Overlapping Mixture Benchmark

When p and q already overlap, as on the 3-component 2D Gaussian mixture benchmark (\mathrm{JS}(p, q_0) = 0.529 nats), both the saturating pairing generator loss (\min_G \Phi(D), weight w_{\textrm{Rp}}) and the non-saturating pairing loss (rpgan_loss_G, weight 1 - w_{\textrm{Rp}}) converge to within a few thousandths of a nat:

pairing critic; generator loss, runs 0, 1, 2
non-saturating  median JS 0.0006 0.0005 0.0007   first JS < 0.01  2400  2600  2400
saturating      median JS 0.0020 0.0017 0.0014   first JS < 0.01  1800  1800  1800
  • Near the data distribution, generated samples frequently outrank real samples (w_{\textrm{Rp}}(x') \approx \frac{1}{2}), so neither weight saturates, and the saturating arm actually crosses \mathrm{JS} < 0.01 nats slightly earlier (step 1{,}800 vs. 2{,}200\text{--}2{,}600).

Six Units Away: Saturating Pairing Stalls

Separated Start Benchmark

When initialized far from the data at \theta_0 = 6.0 on the 1D Gaussian shift problem (p = \mathcal{N}(0, 1), q_\theta = \mathcal{N}(\theta, 1)), every generated sample ranks far below every real sample (D(x') \ll D(x)), driving w_{\textrm{Rp}}(x') = \mathbb{E}_p[\sigma(D(x') - D(x))] \to 0:

                    |gradient|   theta at steps (0, 100, 300, 1000, 1500)   first |theta| < 0.5
non-saturating  0      3.244      6.00   2.41   0.57   0.02   0.00     323
non-saturating  1      3.021      6.00   2.26   0.55   0.02   0.00     317
non-saturating  2      3.057      6.00   2.65   0.60   0.02   0.00     335
saturating      0      0.000      6.00   6.00   6.00   6.00   6.00   not reached
saturating      1      0.000      6.00   6.00   6.00   6.00   5.99   not reached
saturating      2      0.000      6.00   6.00   6.00   6.00   5.99   not reached

Why we always use rpgan_loss_G: At \theta_0 = 6.0, the saturating pairing generator receives a median gradient below 5 \times 10^{-4} and remains stuck at \theta = 6.00 after 1{,}500 steps, whereas the non-saturating pairing generator (1 - w_{\textrm{Rp}} \approx 1) receives gradient \approx 3.1 and reaches |\theta| < 0.5 around step 330.

Concept Check: Relativistic Critics and Pairings

Check Your Understanding

Test your understanding of relativistic pairwise objectives:

  1. Behavior of the divergence ratio d_{\mathrm{Rp}}(p, q) / \mathrm{JS}(p, q): On our two-state example, d_{\mathrm{Rp}}(p, q) / \mathrm{JS}(p, q) = 0.319 / 0.193 \approx 1.66. What value does this ratio approach as q \to p, and what value does it approach when p and q have disjoint supports?
  2. Escape path under fixed pairing: For n = 2 with fixed pairing x_1 \leftrightarrow x'_1 and x_2 \leftrightarrow x'_2, suppose both generated points collide on x_1 (x'_1 = x'_2 = x_1). What is the best-response paired loss \mathcal{E}_{\mathrm{diag}}, and how does it behave as x'_2 moves continuously from x_1 to x_2?

Answers:

  1. By d_{\mathrm{Rp}}(p, q) = 2\,\mathrm{JS}(p, q) - I(a_1; a_2): as q \to p, I(a_1; a_2) = \Theta(\|p - q\|^4) \ll \mathrm{JS}(p, q) = \Theta(\|p - q\|^2), so the ratio approaches 2. On disjoint supports, both d_{\mathrm{Rp}} and \mathrm{JS} saturate at \log 2, so the ratio approaches 1.
  2. At x'_1 = x'_2 = x_1, edge 1 \to 1 forms a 1-cycle (contributing -\frac{1}{2}\log 2) while edge 2 \to 1 is acyclic (contributing 0), giving \mathcal{E}_{\mathrm{diag}} = -\frac{1}{2}\log 2 \approx -0.347. As x'_2 moves across empty space toward x_2, \mathcal{E}_{\mathrm{diag}} stays completely flat at -\frac{1}{2}\log 2 and then drops to -\log 2 once x'_2 lands on x_2 (closing the second 1-cycle 2 \to 2).

Concept Check: Relativistic Critics and Pairings (cont.)

Check Your Understanding

  1. Interpreting individual critic scores: After training an RpGAN critic, you evaluate D(x') = +3.5 on a generated image. Does D(x') > 0 mean the critic classifies x' as more likely real than generated?

Answer:

  1. No. Because \Phi(D + b) = \Phi(D) is shift-invariant, the zero level of D is arbitrary. Only pairwise differences D(x) - D(x') (or the ranking accuracy P(D(x) > D(x'))) are meaningful.

Summary: Relativistic Pairing Objectives

Key Takeaways

Concept / Property Mathematical Expression Relation to Classic Log-Loss GAN Practical Implication
Bradley–Terry Critic (\Phi) \Phi(D) = \mathbb{E}_{x \sim p,\, x' \sim q}[\log\sigma(D(x) - D(x'))] Replaces threshold D(x) \gtrless 0 with pair ranking Invariant to constant shifts D \mapsto D + b
Optimal Ranking Critic D^\star(x) = \lambda(x) + c = \log \frac{p(x)}{q(x)} + c Identical log density ratio up to shift c Monitor pairwise accuracy P(D(x) > D(x')), not signs
Calibrated Pairing Divergence d_{\mathrm{Rp}}(p, q) = \sup_D \Phi(D) + \log 2 = \mathrm{JS}(p \otimes q, q \otimes p) d_{\mathrm{Rp}}(p, q) = 2\,\mathrm{JS}(p, q) - I(a_1; a_2) \mathrm{JS} \le d_{\mathrm{Rp}} \le \min(2\,\mathrm{JS}, \log 2); saturates at \log 2
Relativistic Rank Weight w_{\textrm{Rp}}(x') = \mathbb{E}_{x \sim p}[\sigma(D(x') - D(x))] Compares D(x') against real distribution D(x) Use non-saturating weight 1 - w_{\textrm{Rp}}(x') (rpgan_loss_G)
Fixed vs. All-Pairs Landscape \mathcal{E}_{\mathrm{diag}} (fixed x_i \leftrightarrow x'_i) vs. \mathcal{E}_{\mathrm{all}} (n^2 pairs) \mathcal{E}_{\mathrm{diag}} has 0 collision minima; \mathcal{E}_{\mathrm{all}} has n^n - n! Random minibatch re-pairing averages to \mathcal{E}_{\mathrm{all}}