李宏毅學習筆記32.GAN.03.Unsupervised Conditional Generation

簡介

上節講了Conditional GAN,這個GAN是監督學習,帶標籤的,這節看Unsupervised Conditional GAN
公式輸入請參考:在線Latex公式
Conditional GAN如果做到Unsupervised呢?我們先來看幾個例子:
Transform an object from one domain to another without paired data (e.g. style transfer)
有兩組數據,一組是正常的風景照,一組是復古畫,兩組數據沒有任何的聯繫。現在要訓練一個NN,把風景照圖片轉換爲復古畫。
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

Unsupervised Conditional Generation

從文獻上看有兩大類的做法。
Approach 1: Direct Transformation(直接轉,只能小改:顏色、紋理),主要用在:For texture or color change
在這裏插入圖片描述

• Approach 2: Projection to Common Space(抽取圖片的特徵,眼鏡、男性。再生成對應的動漫角色),主要用在:Larger change, only keep the semantics(下面的例子不是實作的效果)
在這裏插入圖片描述
下面分別詳細講:

Direct Transformation

現有有兩個domain的數據:
在這裏插入圖片描述
現在的問題是如果輸入Domain X的數據,然後用Generator:GXYG_{X\rightarrow Y}生成對應的Domain Y的圖片?如果是監督學習那是沒問題的,因爲Generator看過Domain Y的風格。現在是非監督的學習方法。
在這裏插入圖片描述
於是我們需要加入一個根據Domain Y的Discriminator:DYD_Y
在這裏插入圖片描述
這個DYD_Y可以輸出一個向量,用於鑑別圖片是不是輸入Domain Y的風格的圖片。
在這裏插入圖片描述
Generator就要要生成類似Domain Y的風格的圖片,騙過Discriminator:
在這裏插入圖片描述
但是如果僅僅是這樣,Generator可以直接生成一張與原輸入無關,但是與Domain Y的風格類似的圖片就直接可以騙過Discriminator:
在這裏插入圖片描述
我們來看如何解決這個問題:

法1:直接忽略

法1:直接忽略這個問題,因爲當Generator不是很deep的時候(很shallow),輸入和輸出不會差得太遠,例如你輸入一個山水畫,輸出一個人頭這樣的事情是不會出現的。
The issue can be avoided by network design. Simpler generator makes the input and output more closely related.[Tomer Galanti, et al. ICLR, 2018]

法2:向量化限制

法2:當Generator比較deep,這個時候可以把模型的輸入輸出接兩個預訓練(pre-trained)好的NN,這兩個NN把Generator的輸入和輸出分別embedding爲一個向量。然後訓練Generator條件變爲:輸入和輸出的embedding要越相近越好,然後還要儘量騙過Discriminator:
在這裏插入圖片描述

法3:Cycle GAN

法3:[Jun-Yan Zhu, et al., ICCV, 2017],用兩個Generator,第二個(橙色的)Generator要把第一個Generator生成對象重新還原回原輸入的照片。兩個Generator接在一起,被稱爲:Cycle GAN。
在這裏插入圖片描述
上面還有一個變種,很容易理解,注意模塊的顏色:
在這裏插入圖片描述
下面看Cycle GAN的實例:
https://github.com/Aixile/chainer-cyclegan
在這裏插入圖片描述
全部轉爲銀髮:
在這裏插入圖片描述

Issue of Cycle Consistency

在這裏插入圖片描述
上面的例子我們可以看到轉化的圖片中(注意紅框中的黑點)隱藏了一些信息(The information is hidden.)這個好嗎?
從加密的角度來看這個和隱寫術很像(• CycleGAN: a Master of Steganography (隱寫術):[Casey Chu, et al., NIPS workshop, 2017] )
但是從我們之前的約束中提到要使得GXYG_{X\rightarrow Y}的輸入和輸出不能差太遠,限制Generator會自己把信息藏起來了,就會使得輸入輸出差別較大,不好。

其他Cycle GAN

同一時間不同作者提出來的與Cycle GAN一樣的東西:
Disco GAN[Taeksoo Kim, et al., ICML, 2017]
在這裏插入圖片描述
Dual GAN[Zili Yi, et al., ICCV, 2017]
在這裏插入圖片描述

starGAN For multiple domains

For multiple domains, considering starGAN[Yunjey Choi, arXiv, 2017]
(a)Cross-domain models
在這裏插入圖片描述
(b)StarGAN
在這裏插入圖片描述
starGAN裏面其實用到了Cycle GAN,看下大概步驟:
(a)Training the discriminator,吃一個圖片,輸出兩個東西,一個是圖片是真假,一個是圖片所屬的Domain。
在這裏插入圖片描述
在這裏插入圖片描述
這裏的b和c就是用到了Cycle GAN的思想,左邊的Generator吃輸入圖片和目標Domain,輸出一個Fake Image,然後右邊的Generator吃Fake Image加源Domain要還原回輸入圖片,而且左邊的Generator輸出的Fake Image要儘量騙過Discriminator(一來是真圖片,二來是目標Domain)。
下面看實例:
(a)Training the discriminator
在這裏插入圖片描述
這裏表示multi-domain的方法是用編碼:
在這裏插入圖片描述
上面的黃色模塊00101就是對應:Brown/Young的兩個特徵。
在這裏插入圖片描述
另外一個改表情的例子:
在這裏插入圖片描述

Projection to Common Space

我們想要做到:
真人圖片丟到ENXEN_X,可以抽出真人的特徵到latent vector(橙色),然後經過二次元的DEYDE_Y得到對應的二次元圖片
二次元圖片丟到ENYEN_Y,可以抽出二次元的特徵到latent vector(橙色),然後經過真人的DEXDE_X得到對應的二次元圖片
在這裏插入圖片描述
如果是監督學習,我們已經有真人和二次元特徵的對應關係,那很好做,但是我們現在沒有他們之間的關係,只有:
在這裏插入圖片描述
那怎麼訓練兩組encoder和decoder呢?我們把真人的encoder和decoder一起訓練,二次元的encoder和decoder一起訓練:
在這裏插入圖片描述
如果只是以Minimizing reconstruction error爲目標,就是單純的AE了,之前說過,這樣生成的圖片會很模糊,因此我們要加一個Discriminator模塊:
在這裏插入圖片描述
這樣我們就得到了ENX+DEX+DXEN_X+DE_X+D_XENY+DEY+DYEN_Y+DE_Y+D_Y兩套VAE GAN
Because we train two auto-encoders separately …
The images with the same attribute may not project to the same position in the latent space.
可能真人的特徵表示用第一維表示性別,第二維表示眼鏡;而二次元的特徵表示用第一維表示眼鏡,第二維表示性別。
因此會得到:
在這裏插入圖片描述
解決這個問題可以用:
法1:
部分參數共享,就是真人和二次元模型的部分隱藏層的參數是共享的(注意下圖中虛線的部分)。
在這裏插入圖片描述
使用這個技巧的兩個文章:
Couple GAN[Ming-Yu Liu, et al., NIPS, 2016]
UNIT[Ming-Yu Liu, et al., NIPS, 2017]
實作上:直接用code代表不同的Domain,例如1表示真人,-1表示二次元,Encoder和decoder用的是同一套。
法2:
在中間的特徵表示上接一個Domain Discriminator,這個Discriminator可以判斷特徵表示是來自哪個Encoder。而兩個Encoder的限制多了一個:要使得Domain Discriminator無法分辨特徵表示是來自哪個Encoder。意味兩個Encoder產生的特徵表示都來自同一個分佈。
The domain discriminator forces the output of ENXEN_X and ENYEN_Y have the same distribution.[Guillaume Lample, et al., NIPS, 2017]
在這裏插入圖片描述
法3:
Cycle Consistency: Used in ComboGAN [Asha Anoosheh, et al., arXiv, 017]
真人圖片經過1.2.3.4.5.個步驟還原回真人圖片,這兩個圖片越像越好。當然右邊的輸出還要分別滿足兩個Discriminator的條件。
在這裏插入圖片描述
法4:
Semantic Consistency: Used in DTN [Yaniv Taigman, et al., ICLR, 2017] and XGAN [Amélie Royer, et al., arXiv, 2017]
真人圖片經過1號步驟得到的特徵表示,以及真人圖片經過1.2.3.4.號步驟得到的特徵表示要越接近越好。
因爲上面的法3中最後比較差異是比較兩個圖片,我們說過圖片與圖片的pixel to pixel的比較是有缺陷的,因此這裏直接用特徵表示進行比較。
在這裏插入圖片描述
例子:https://github.com/Hi-king/kawaii_creator
It is not cycle GAN, Disco GAN.
數據:
在這裏插入圖片描述
結果,老師變身萌妹子。。。
在這裏插入圖片描述

Voice Conversion

In the past,用的監督學習的方法,要有一堆對應的聲音:
在這裏插入圖片描述
然後訓練一個seq2seq的模型就可以了,但是這個模型是有缺陷的,例如我想要變聲爲張學友,那很難請到張學友跟我一起念同樣的句子,然後來訓練,很麻煩。那如果我想要變聲爲尼古拉斯凱奇,那就很難搞了,因爲他不會中文,就算請到他也講不來相同的句子。
Today,我們只要收集兩組聲音,不用講一樣的內容就可以進行訓練。
Speakers A and B are talking about completely different things.
在這裏插入圖片描述

Reference

• Jun-Yan Zhu, Taesung Park, Phillip Isola, Alexei A. Efros, Unpaired Image-toImage Translation using Cycle-Consistent Adversarial Networks, ICCV, 2017
• Zili Yi, Hao Zhang, Ping Tan, Minglun Gong, DualGAN: Unsupervised Dual Learning for Image-to-Image Translation, ICCV, 2017
• Tomer Galanti, Lior Wolf, Sagie Benaim, The Role of Minimal Complexity Functions in Unsupervised Learning of Semantic Mappings, ICLR, 2018
• Yaniv Taigman, Adam Polyak, Lior Wolf, Unsupervised Cross-Domain Image Generation, ICLR, 2017
• Asha Anoosheh, Eirikur Agustsson, Radu Timofte, Luc Van Gool, ComboGAN: Unrestrained Scalability for Image Domain Translation, arXiv, 2017
• Amélie Royer, Konstantinos Bousmalis, Stephan Gouws, Fred Bertsch, Inbar Mosseri, Forrester Cole, Kevin Murphy, XGAN: Unsupervised Image-to-Image Translation for Many-to-Many Mappings, arXiv, 2017
• Guillaume Lample, Neil Zeghidour, Nicolas Usunier, Antoine Bordes, Ludovic Denoyer, Marc’Aurelio Ranzato, Fader Networks: Manipulating Images by Sliding Attributes, NIPS, 2017
• Taeksoo Kim, Moonsu Cha, Hyunsoo Kim, Jung Kwon Lee, Jiwon Kim, Learning to Discover Cross-Domain Relations with Generative Adversarial Networks, ICML, 2017
• Ming-Yu Liu, Oncel Tuzel, “Coupled Generative Adversarial Networks”, NIPS, 2016
• Ming-Yu Liu, Thomas Breuel, Jan Kautz, Unsupervised Image-to-Image Translation Networks, NIPS, 2017
• Yunjey Choi, Minje Choi, Munyoung Kim, Jung-Woo Ha, Sunghun Kim, Jaegul Choo, StarGAN: Unified Generative Adversarial Networks for Multi-Domain Image-to-Image Translation, arXiv, 2017

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章