Skip to main content

RealNVP

RealNVP は、NICE の additive coupling layer を affine coupling layer に拡張した flow-based model です。NICE よりも表現力が高く、exact likelihood と efficient sampling を両立します。

Affine coupling layer

Input xx を二つの部分 x1x_1x2x_2 に分け、次のように変換します。

y1=x1y_1 = x_1 y2=x2exp(s(x1))+t(x1)y_2 = x_2 \odot \exp(s(x_1)) + t(x_1)

ここで、sstt は neural network です。

Inverse

Affine coupling layer は、次のように簡単に inverse を計算できます。

x1=y1x_1 = y_1 x2=(y2t(y1))exp(s(y1))x_2 = (y_2 - t(y_1)) \odot \exp(-s(y_1))

Jacobian determinant

Jacobian は triangular になるため、determinant は diagonal 成分の積として計算できます。

logdetJ=isi(x1)\log \left| \det J \right| = \sum_i s_i(x_1)

この性質によって、RealNVP は high-dimensional data に対しても likelihood を効率よく計算できます。

数式で見る RealNVP の coupling layer

RealNVP は affine coupling layer を使います。入力を二つに分け、片方はそのまま通し、もう片方を scale と shift します。

y1=x1\mathbf{y}_1=\mathbf{x}_1 y2=x2exp(s(x1))+t(x1)\mathbf{y}_2=\mathbf{x}_2\odot\exp(s(\mathbf{x}_1))+t(\mathbf{x}_1)

逆変換は簡単です。

x2=(y2t(y1))exp(s(y1))\mathbf{x}_2=(\mathbf{y}_2-t(\mathbf{y}_1))\odot\exp(-s(\mathbf{y}_1))

Jacobian は triangular になるため、log determinant は scale の和だけで計算できます。

logdetJ=isi(x1)\log|\det J|=\sum_i s_i(\mathbf{x}_1)

この式の気持ちは、「半分の変数を条件として使い、もう半分だけを変換することで、表現力と計算しやすさを両立する」というものです。Layer を重ねるときには、mask や permutation を変えて、すべての dimension が変換されるようにします。

関連ページ