iRevNet

Residual flows take inspiration from residual networks. They divide the input into two parts (similar to coupling flows) and define the outputs as:

where and are two functions that do not necessarily have to be invertible. The inverse can be computed by reversing the order of computation:

As for coupling flows, the division into blocks restricts the family of transformations that can be represented. Thus, the inputs are permuted between layers so that the variables can mix in arbitrary ways.

This formulation can be inverted easily, but for general functions and , there is no efficient way to compute the Jacobian.

This formulation is sometimes used to save memory when training residual networks; because the network is invertible, storing the activations at each layer in the forward pass is unnecessary.

iResNet

Another approach to exploit residual networks is to utilize the Banach fixed point theorem or contraction mapping theorem, which states that every contraction mapping has a fixed point. A contraction mapping has the property that:

where is a distance function and . When a function with this property is iterated (i.e., the output is repeatedly passed back in as an input), the result converges to a fixed point where .

  • To understand this, consider applying the function to both the fixed point and the current position; the fixed point remains static, but the distance between the two must become smaller, so the current position must get closer to the fixed point.

The theorem can be exploited to invert an equation of the form:

if is a contraction mapping. In other words, it can be used to find the that maps to a given value, . This can be done by starting with any point and iterating . This has a fixed point at .

The same principle can be used to invert residual network layers of the form if we ensure that is a contraction mapping. In practice, this means that the Lipschitz constant must be less than one. Assuming that the slope of the activation functions is not greater than one, this is equivalent to ensuring that the largest eigenvalue of each weight matrix must be less than one. A crude way to do this is to ensure that the absolute magnitudes of the weights are small by clipping them.

The Jacobian determinant cannot be computed easily, but its logarithm can be approximated using a series of tricks:

where we have used the identity in the first line, and expanded this into a power series in the second line.

Even when we truncate this series, it’s still computationally expensive to compute the trace of the constituent terms. Hence, we approximate this using Hutchinson’s trace estimator. Consider a normal random variable with mean and variance . The trace of a matrix can be estimated as:

where:

  • The first line is true because .
  • The second line derives from the properties of the expectation operator.
  • The third line comes form the linearity of the trace operator.
  • The fourth line is due to the invariance of the trace to cyclic permutation
  • The final line is true because the argument in the fourth line is now a scalar.

We estimate the trace by drawing samples from :

In this way, we can approximate the trace of the powers of the Taylor expansion and evaluate the log probability.