# Extension of DV Formula¶

\(\def\abs#1{\left\lvert #1 \right\rvert} \def\Set#1{\left\{ #1 \right\}} \def\mc#1{\mathcal{#1}} \def\M#1{\boldsymbol{#1}} \def\R#1{\mathsf{#1}} \def\RM#1{\boldsymbol{\mathsf{#1}}} \def\op#1{\operatorname{#1}} \def\E{\op{E}} \def\d{\mathrm{\mathstrut d}}\)

## \(f\)-divergence¶

Consider the more general problem of estimating the \(f\)-divergence in (3):

**Exercise**

How to estimate \(f\)-divergence using the DV formula?

**Solution**

Note that the neural network approximates the density ratio (5),

which can then be used to evaluate the sample average (4),

Instead of using the DV bound, it is desirable to train a network to optimize a tight bound on the \(f\)-divergence because:

*Estimating KL divergence well does not imply the underlying neural network approximates the density ratio well*:While KL divergence is just a non-negative real number,

the density ratio is in a high dimensional function space.

DV formula does not directly maximizes a bound on \(f\)-divergence, i.e.

it does not directly minimize the error in estimating \(f\)-divergence.

\(f\)-divergence may have bounds that are easier/more stable for training a neural network.

**How to extend the DV formula to \(f\)-divergence?**

The idea is to think of the \(f\)-divergence as a convex *function(al)* evaluated at the density ratio:

This is more like a re-definition than a proposition as the proof is immediate:

(3) is obtained from (15) by substituting \(r=\frac{dP_{\R{Z}}}{dP_{\R{Z}'}}\).

As mentioned before, the KL divergence \(D(P_{\R{Z}}\|P_{\R{Z}'})\) is a special case of \(f\)-divergence:

where

**Exercise** When is \(F[r]=0\) equal to \(0\)?

**Solution**

\(F[r]=0\) iff \(f(r(\R{Z}'))=0\) almost surely, which happens iff \(r(\R{Z}')=1\) almost surely. We may also write it more explicitly as:

namely an identity function over the support set of \(\R{Z}'\).

**Exercise**

Show using the properties of \(f\) that \(F\) is strictly convex.

**Solution**

For \(\lambda\in [0,1]\) and functions \(r_1, r_2\in \Set{r:\mc{Z}\to \mathbb{R}}\),

where (a) is by the convexity of \(f\), and (b) is by the linearity of expectation. \(F\) is strictly convex because (b) is satisfied with equality iff (a) is almost surely.

For a clearer understanding, consider a different choice of \(F\) for the KL divergence:

where

Note that \(F'\) in (18) defined above is concave in \(r\). In other words, (9) in Proposition 4

is maximizing a concave function and therefore has a unique solution, namely, \(r=\frac{dP_{\R{Z}}}{dP_{\R{Z}'}}\). Here comes the tricky question:

**Exercise**

Is KL divergence concave or convex in the density ratio \(\frac{dP_{\R{Z}}}{dP_{\R{Z}'}}\)? Note that \(F\) defined in (17) is convex in \(r\).

**Solution**

The statement is invalid because KL divergence is not purely a function of the density ratio, but both \(P_{\R{Z}}\) and \(P_{\R{Z}'}\). The expectation in (18), in particular, depends on \(P_{\R{Z}}\).

## Convex conjugation¶

Given \(P_{\R{Z}'}\in \mc{P}(\mc{Z})\), consider

a function space \(\mc{R}\),

a dual space \(\mc{T}\), and

the corresponding inner product \(\langle\cdot,\cdot \rangle\):

The following is a generalization of DV formula for estimating \(f\)-divergence [2][3]:

Proof. Note that the supremums in (23) and (22) are Fenchel-Legendre transforms. Denoting the transform as \([\cdot]^*\),

gives (22) by expanding the outer/later transform. The equality is by the property that Fenchel-Legendre transform is its own inverse for strictly convex functional \(F\). This completes the proof by (15).

The proof is illustrated in the following figure:

Let’s breakdown the details:

**Step 1**

For the purpose of the illustration, visualize the convex functional \(F\) simply as a curve in 2D.

The \(f\)-divergence is then the \(y\)-coordinate of a point on the curve indicated above, with \(r\) being the density ratio \(\frac{dP_{\R{Z}}}{dP_{\R{Z}'}}\).

**Step 2**

To obtain a lower bound on \(F\), consider any tangent of the curve with an arbitrary slope \(t\cdot dP_{\R{Z}'}\)

The lower bound is given by the \(y\)-coordinate of a point on the tangent with \(r\) being the density ratio.

**Exercise**

Why is the \(y\)-coordinate of the tangent a lower bound on the \(f\)-divergence?

**Solution**

By the convexity of \(F\), the tangent must be below \(F\).

**Step 3**

To calculate the lower bound, denote the \(y\)-intercept as \(-F^*[t]\):

Thinking of a function as nothing but a vector, the displacement from the \(y\)-intercept to the lower bound is given by the inner product of the slope and the density ratio.

**Step 4**

To make the bound tight, maximize the bound over the choice of the slope or \(t\):

This gives the bound in (22). It remains to show (23).

**Step 5**

To compute the \(y\)-intercept or \(F^*[t]\), let \(r^*\) be the value of \(r\) where the tangent touches the convex curve:

The displacement from the point at \(r^*\) to the \(y\)-intercept can be computed as the inner product of the slope and \(r^*\).

**Exercise**

Show that for the functional \(F\) (17) defined for KL divergence,

with \(\mc{R}=\Set{r:\mc{Z}\to \mathbb{R}_+}\) and so (22) gives the DV formula (12) as a special case.

**Solution**

See [3].````