Skip to main content

Glow

Glow は、Flow-based model を high-quality image generation に適用した代表的な model です。RealNVP を発展させ、actnorm、invertible 1x1 convolution、affine coupling layer を組み合わせます。

One step of flow​

Glow の一つの flow step は、主に次の三つから構成されます。

  1. Actnorm
  2. Invertible 1x1 convolution
  3. Affine coupling layer

One Glow step

画像出典: Lilian Weng, “Flow-based Deep Generative Models”。Glow の一つの step は、actnorm、invertible 1x1 convolution、affine coupling から構成されます。

Actnorm​

Actnorm は、activation normalization の一種です。Batch Normalization のように batch statistics に依存するのではなく、learnable な scale と bias を使います。

Invertible 1x1 convolution​

RealNVP では、dimension を入れ替えるために fixed permutation が使われます。Glow では、これを learnable な invertible 1x1 convolution に置き換えます。これによって channel 間の mixing をより柔軟に学習できます。

Affine coupling​

Glow でも、RealNVP と同様に affine coupling layer が使われます。Coupling layer によって invertibility と efficient Jacobian determinant calculation を両立します。

性能比較​

Glow table

画像出典: Lilian Weng, “Flow-based Deep Generative Models”。Glow の likelihood と sampling quality の比較が示されています。

数式で見る affine coupling と log determinant​

Glow のような flow-based model は、可逆変換 x=fθ(z)\mathbf{x}=f_\theta(\mathbf{z}) と change of variables を使って likelihood を計算します。

log⁡pθ(x)=log⁡p(z)+log⁡∣det⁡∂fθ−1(x)∂x∣\log p_\theta(\mathbf{x})= \log p(\mathbf{z})+ \log\left|\det\frac{\partial f_\theta^{-1}(\mathbf{x})}{\partial \mathbf{x}}\right|

Affine coupling layer では、入力を二つに分けて次のように変換します。

y1=x1,y2=x2⊙exp⁡(s(x1))+t(x1)\mathbf{y}_1=\mathbf{x}_1, \qquad \mathbf{y}_2=\mathbf{x}_2\odot \exp(s(\mathbf{x}_1))+t(\mathbf{x}_1)

この変換の Jacobian は triangular になるため、log determinant は簡単に計算できます。

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

この式の気持ちは、「表現を十分に混ぜたいが、likelihood を計算するために Jacobian determinant は簡単にしたい」という trade-off を、coupling 構造で解いているということです。

関連ページ​