1. 程式人生 > 其它 >GAN2-訓練GAN時所遇到的問題及可能的解決方法

GAN2-訓練GAN時所遇到的問題及可能的解決方法

1,模式坍塌(Mode collapse )

  • spectral collapse(譜崩潰)

    • 文獻:Spectral regularization for combating mode collapse in GANs

    • 程式碼:https://github.com/max-liu-112/SRGANs-Spectral-Regularization-GANs-

    • 概念及定義

      • 譜崩潰:當模式崩潰發生時,權重矩陣的奇異值急劇下降的現象稱為譜崩潰,作者發現模式崩潰和頻譜崩潰並存的現象普遍存在,而本文通過解決譜崩潰來解決模式崩潰問題。

      • 譜歸一化權重矩陣(spectral nornalized weight matrix)\(\bar{W}_{SN}(W)\)

        ;當模型沒有模式崩潰發生時,\(\bar{W}_{SN}(W)\)中大部分值接近1;而當模式崩潰發生時,\(\bar{W}_{SN}(W)\)中的值會急劇下降。(作者在文中做了一些實驗,說明了這一現象,但沒有從理論層面證明為什麼會發生這一現象)

        \[\bar{W}_{SN}(W):=\frac{W}{\sigma(W)} \]

        其中\(\sigma(W)\)是D中權重矩陣的[譜範數](https://mathworld.wolfram.com/SpectralNorm.html#:~:text=Spectral Norm. The natural norm induced by the,root of the maximum eigenvalue of %2C i.e.%2C)(

        WolframMathWorld-一個神奇的網站),相當於權重矩陣的最大奇異值。

      • 權重矩陣\(W\)的奇異值分解(singular value decomposition)(原文中的公式)

        \[W=U\cdot\sum\cdot{V^T} \]\[U^TU=I \]\[V^TV=I \]\[\sum=[\begin{matrix}D&0\\0&0\end{matrix}] \]

        其中\(D=diag{\{\sigma_1,\sigma_2,\cdots,\sigma_r\}}\)

    • 解決方案:頻譜正則化通過補償頻譜分佈避免頻譜崩潰,從而對D的權重矩陣施加約束(核心思想:防止D的權重矩陣W集中到一個方向上)。有兩種頻譜正則化方案,

      • 頻譜正則化(spectral regularization)

        • 靜態補償(static compensation):需要手動確定超引數\(i\),不易於應用。

          \[\Delta{D}=\left[\begin{matrix}\sigma_1-\sigma_1 & 0 & \cdots & \cdots & \cdots & 0 \\ 0 & \sigma_1-\sigma_2 & \cdots & \cdots & \cdots & 0 \\ \vdots & \cdots & \ddots & \cdots & \cdots & 0\\ \vdots & \cdots & \cdots & \sigma_1-\sigma_i & \cdots & 0\\ \vdots & \cdots & \cdots & \cdots & \ddots & 0\\ 0 & \cdots & \cdots & \cdots & \cdots & 0 \end{matrix}\right] \]
        • 動態補償(dynamic compensation):沒有需要手動確定的超引數,相比於靜態補償使用起來更方便。

          \[\Delta{D^T}=\left[\begin{matrix}0 & 0 & \cdots & 0 \\ 0 & \gamma_2^T\cdot{\sigma_1^T-\sigma_2^T} & \cdots & 0 \\ \vdots & \cdots & \ddots & 0\\ 0 & 0 & \cdots & \gamma_r^T\cdot{\sigma_1^T-\sigma_r^T} \end{matrix}\right] \]

          \(\Delta{D^T}\)是第\(T\)次迭代的補償矩陣,\(\gamma_j^T\)是第\(j\)個補償係數:

          \[\gamma_j^T=max(\frac{\sigma_j^1}{\sigma_1^1},\cdots,\frac{\sigma_j^t}{\sigma_1^t},\cdots,\frac{\sigma_j^T}{\sigma_1^T}),t=0,1,\cdots,T \]

          \(\sigma_j^t\)是第\(t\)次迭代的第\(j\)個奇異值。

      • 頻譜正則化的實現

        \[\Delta{W}=U\cdot{[\begin{matrix}\Delta{D}&0\\0&0\end{matrix}]}\cdot{V^T} \]\[\bar{W}_{SR}(W)=\frac{W+\Delta{W}}{\sigma(W)}=\bar{W}_{SN}(W)+\frac{\Delta{W}}{\sigma(W)} \]
行動是治癒恐懼的良藥,而猶豫拖延將不斷滋養恐懼。