GAN中的Spectral Normalization
Spectral Normalization 出自 《Spectral Norm Regularization for Improving the Generalizability of Deep Learning》和《Spectral Normalization for Generative Adversarial Networks》,是为了解决GAN训练不稳定的问题,从“层参数”的角度用spectral normalization的方式施加regularization,从而使判别器D具备Lipschitz连续条件。
为什么要让D具备Lipschitz连续
根据Wikipedia的定义,Lipschitz连续条件 如下。其意义在于使得 f 足够稳定,在输入发生少量变化时,输出不会有太巨大的变化。如果有图像A,修改少量像素得到图像B,输入判别器D后得到相差非常巨大的判别效果,那么判别器就是不稳定的,它对输入过于敏感。
∣ ∣ f ( x 1 ) − f ( x 2 ) ∣ ∣ ∣ ∣ x 1 − x 2 ∣ ∣ ≤ K , ∀ x 1 , x 2 \frac{||f(x_1)-f(x_2)||}{||x_1-x_2||}\leq K, \forall x_1,x_2 ∣∣x1−x2∣∣∣∣f(x1)−f(x2)∣∣≤K,∀x1,x2
这里的 K 被称为 f ( x ) f(x) f(x) 的 Lipschitz constant,K的最小值(上确界)被称为 ∣ ∣ f ∣ ∣ L i p ||f||_{Lip} ∣∣f∣∣Lip ,称 f ( x ) f(x) f(x) 满足 Lipschitz连续条件。
《Wasserstein GAN》 给出了衡量真实分布 P r P_r Pr和生成分布 P g P_g Pg的 Earth-Mover(EM) 距离:
W ( P r , P g ) = inf γ ∈ ( P r , P g ) E ( x , y ) ∼ γ [ ∣ ∣ x − y ∣ ∣ ] W(P_r, P_g)=\inf_{\gamma \in (P_r, P_g)}E_{(x,y)\sim \gamma}[||x-y||] W(Pr,Pg)=γ∈(Pr,Pg)infE(x,y)∼γ[∣∣x−y∣∣]
由 Kantorovich-Rubinstein duality 可得EM距离的另一个形式,这里有用到 ∣ ∣ f ∣ ∣ L i p ||f||_{Lip} ∣∣f∣∣Lip:
W ( P r , P g ) = 1 K sup ∣ ∣ f ∣ ∣ L i p ≤ K E x ∼ P r [ f ( x ) ] − E x ∼ P g [ f ( x ) ] W(P_r, P_g)=\frac{1}{K} \sup_{||f||_{Lip}\leq K}E_{x\sim P_r}[f(x)]-E_{x\sim P_g}[f(x)] W(Pr,Pg)=K1∣∣f∣∣Lip≤KsupEx∼Pr[f(x)]−Ex∼Pg[f(x)]
在 ∣ ∣ f ∣ ∣ L i p ≤ 1 ||f||_{Lip}\leq 1 ∣∣f∣∣Lip≤1的条件下