Abstract
- 人類可以在無監督的情況下輕易地發現兩個東西之間的聯系(或者說相同點), 而想讓機器學習的話需要人類給他們配對作為ground truth然后再進行訓練.
- 為了避免這種配對的麻煩, 提出了DiscoGAN
Introduction
- 這篇文章把”尋找兩種圖片的關系”變成了”用一種風格的圖片生成另一種風格”(利用GAN),這是本文解決”尋找relation”的思路所在.
- 不需要人工配對圖片(作為監督學習的訓練集), 是無監督的.
Model
GAB表示域A到域B的生成器,GBA表示域B到域A的生成器。為了找到有意義的對應關系,需要將這個映射限制成一對一映射,意思就是說,GAB和GBA應該是剛好相反的映射。對于所有的A里面的真實樣本xA,GAB(xA)都要在B里面,對于GBA(xB)也一樣。
兩個Constrain
- 前面提到, 希望找到的映射是bijection, 也就是說, GAB is the inverse mapping of GBA
- GAB的結果一定要在B domain里, 反之相同.
這兩個限制分別用下面兩個loss實現:
標準GAN模型
圖中xA、xB分別表示A里面和B里面的真實樣本,xAB表示真實樣本xA經生成器GAB生成的樣本。
缺點:
- 只能從A映射到B, 反之不能
- 無法保證bijection, 即會出現model collapse
- 生成的圖片不是 image-based representation(不理解)
帶有重建損失的GAN模型
基于前面所提出的一對一映射,對于所有的A里面的真實樣本xA,GAB(xA)都要在B里面,這相當于要滿足GBA(GAB(xA))=xA這個條件,但是這個條件很難優化,于是改為最小化距離d(GBA(GAB(xA)),xA),這個d可以是L1,L2等等的度量函數。
于是,標準的GAN模型就被改成了這樣:
優點:
缺點:
During training, the generator GAB learns the mapping from domain A to domain B under two relaxed constraints:
- domain A maps to domain B. (LCONSTA)
- mapping on domain B is reconstructed to domain A. (LGANB)
However, this model lacks a constraint on mapping from B to A, and these two conditions alone does not guarantee a cross-domain relation (as defined in section 2.1) because the mapping satisfying these constraints is one-directional. In other words, the mapping is an injection, not bijection, and one-to-one correspondence is not guaranteed.
從上面這句話來看, LCONSTA僅僅用于調整GAB的參數, 而不用于GBA, 因此才會導致lacks a constraint on mapping from B to A. 不過這不重要, 重要的是下面的缺點二.
1.In some sense, the addition of a reconstruction loss to a standard GAN is an attempt to remedy the mode collapse problem.
2.In Figure 3c, two domain A modes are matched with the same domain B mode, but the domain B mode can only direct to one of the two domain A modes.
3.Although the additional reconstruction loss LCONSTA forces the reconstructed sample to match the original (Figure 3c), this change only leads to a similar symmetric problem. The reconstruction loss leads to an oscillation between the two states and does not resolve mode-collapsing.
出現的問題的示意圖在(c); 注意最后一句話, 如果出現了兩個A的model A1和A2被map到了同一個B, 而GAB和GBA都是函數, 即都滿足一個輸入只能對應一個輸出, 因此GBA只能映射到一個A model(設為Areconst). 這樣, LCONSTA就會使得Areconst要么接近A1, 要么接近A2, 即an oscillation between the two states.
生成器的損失函數如下:
生成器GAB收到兩個損失,一個是重建損失(reconstruction loss),描述經過兩個生成器之后的重建效果與原始真實樣本的差距,另外一個是原始GAN的生成損失,表示GAB生成的樣本來自B的逼真性。
判別器損失如下:
D表示相應域的判別器。
相對于原始的GAN模型,這里的重建約束雖然迫使重建樣本與原始的一樣,但是這仍然會導致類似的模式崩潰問題。
(a)是我們理想的映射,一對一的;(b)是原始GAN的結果,A中的多個模式映射到了B中的一個模式,
就是模式崩潰的情況;(c)是加入了重建損失的GAN,A中兩個模式的數據都映射到了B中的一個模式,
而B中一個模式的數據只能映射到A中這兩個模式中的一個。重建損失使得模型在(c)中的兩個狀態之間
震蕩,而并不能解決模式崩潰問題。
個人的理解是,當A的數據放進去一起訓練,由于不管是放進哪一個模式,GAB都會產生B中對應的一個模式,
而GBA再生成的時候,當生成A中的第一個模式,和第二個模式就不像了,于是接下來重建損失會使得GBA再生成
的數據往第二個模式靠攏,但是又不像A里面的第一個模式了,于是模型在這兩者之間來回震蕩,導致無法收斂。
DiscoGAN
為了解決模式崩潰的問題,就要使得不管是GAB還是GBA,不同模式生成出來的就應該是不同的,于是很自然地想到了對稱結構,就是再加一個反過來的生成網絡,迫使A和B中的數據一一對應。
模型中包含兩個生成器GAB,這兩個GAB是一樣的,還有兩個生成器GBA,這兩個也是一樣的。這樣就實現了一對一的映射。
損失函數:
優點:
- This model is constrained by two LGAN losses and two LCONSTlosses.
- Therefore a bijective mapping is achieved, and a one-to-one correspondence, which we defined as cross-domain relation, can be discovered.
Experiment
Toy Experiment
Toy Experiment不僅展示了GAN的G和D生成數據的過程, 而且解釋了DiscoGAN的原理.
實驗內容:
- 用GMM取得source和target samples.
- Fig.4里面的所有圖都是B domain; 顏色代表了DB(xAB) 黑色的”x”代表target samples
首先為了證明所提出的這種對稱模型對于模式崩潰問題的良好性能,做了一個演示實驗。A和B中的數據都是二維的,真實樣本都取自混合高斯模型。用3個線性層和一個ReLU激活層作為生成器,判別器用5個線性層,每層后面接一個ReLU層,最后再接一個sigmoid層將輸出限定在[0,1]之間。
起始狀態
- 所有的source經過GAB映射到了B domain的同一個點上. (除非是GAB的參數全部初始化為0, 不然怎么會出現這種情況?)
- 我不太明白為什么途中都是白色(DB(xB)=0.5), DB對real data不應該輸出1嗎?
Standard GAN model
- Many translated points of different colors are located around the same B domain mode.
- This result illustrates the mode-collapse problem of GANs since points of multiple colors (multiple A domain modes) are mapped to the same B domain mode.
- Regions around all B modes are leveled in a green colored plateau in the baseline, allowing translated samples to freely move between modes
- 我不太明白為什么途中都是綠色(DB(xAB)=1), DB對fake data怎么會輸出1?
GAN with reconstruction loss
- The collapsing problem is less prevalent, but navy, green and light-blue points still overlap at a few modes
- The regions between B modes are clearly separated
DiscoGAN
- Not only prevent mode-collapse by translating into distinct well-bounded regions that do not overlap, but also generate B samples in all ten modes as the mappings in our model is bijective.
- The discriminator for B domain is perfectly fooled.
彩色背景表示判別器的輸出值,”x”表示B種不同的模式。(a)標示了10個目標模式和最初的轉換結果;(b)是標準的GAN迭代40000次的結果;(c)是加入重建損失的網絡迭代40000次的結果;(d)是文章提出的DiscoGAN迭代40000次后的結果。標準GAN的許多不同顏色的轉換點都位于B相同的模式下,海藍和淺藍色的點離得很近,橙色和綠色的點也在一起,多種顏色的點(A中的多種模式)都映射到B的同一種模式下。帶有重建損失的GAN的模式崩潰問題已經不那么嚴重了,但是海藍、綠色和淺藍色的點仍然會在少數幾個模式上重疊。標準的GAN和帶有重建損失的GAN都沒有覆蓋B中的所有模式,DiscoGAN將A中的樣本轉換為B中有邊界不重疊的區域,避免了模式崩潰,并且產生的B樣本覆蓋了所有10種模式,因此這個映射是雙射,從A轉換的樣本也把B的鑒別器個騙過了。
轉換實驗
汽車到汽車
人臉到人臉
性別轉換
頭發顏色
先性別在頭發顏色
頭發顏色、性別來回轉
椅子到汽車,汽車到人臉
輪廓和圖像互轉
總結
綜觀全文, 我覺得最大的亮點, 也是最值得我學習的有二:
- 通過降維的方法把高維空間的情況展示在二維空間中
- 本文的作圖方法值得學習, 比如toy experiment, 以及后面的Real Domain Experiment中Fig.5的方法.
- 本文把”尋找兩個domain的relation”的問題轉化成了”由一個domain生成另一個domain”的方式.
個人理解:
- 訓練了兩個G A->B B->A 以及兩個D 來達到雙射 兩個G共享權重
- 不適用于協同目標理解 本文是一個域到一個域的映射,現在協同目標理解是一個域到多個域的映射
附錄
論文鏈接 https://arxiv.org/pdf/1703.05192.pdf
論文相關博客 http://blog.csdn.net/u011636567/article/details/72678625
代碼地址
官方代碼:https://github.com/SKTBrain/DiscoGAN
其他代碼:https://github.com/carpedm20/DiscoGAN-pytorch
Tensorflow簡潔版本:https://github.com/ChunyuanLI/DiscoGAN[圖片上傳失敗...(image-fcc11d-1532594787493)]