17種GAN變體的Keras實現請收好
夏乙 編譯整理
量子位 出品 | 公眾號 QbitAI
來源:Kaggle blog
從2014年誕生至今,生成對抗網路(GAN)始終廣受關注,已經出現了200多種有名有姓的變體。
心癢難耐想趕快入門?
通過自己動手、探索模型代碼來學習,當然是墜吼的~如果用簡單易上手的Keras框架,那就更贊了。
一位GitHub群眾eriklindernoren就發布了17種GAN的Keras實現,得到Keras親爸爸Fran?ois Chollet在Twitter上的熱情推薦。
乾貨往下看:
https://github.com/eriklindernoren/Keras-GAN
AC-GAN
帶輔助分類器的GAN,全稱Auxiliary Classifier GAN。
在這類GAN變體中,生成器生成的每張圖像,都帶有一個類別標籤,鑒別器也會同時針對來源和類別標籤給出兩個概率分布。
論文中描述的模型,可以生成符合1000個ImageNet類別的128×128圖像。
code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/acgan/acgan.py
paper:
Conditional Image Synthesis With Auxiliary Classifier GANs
Augustus Odena, Christopher Olah, Jonathon Shlens
https://arxiv.org/abs/1610.09585
Adversarial Autoencoder
這種模型簡稱AAE,是一種概率性自編碼器,運用GAN,通過將自編碼器的隱藏編碼向量和任意先驗分布進行匹配來進行變分推斷,可以用於半監督分類、分離圖像的風格和內容、無監督聚類、降維、數據可視化等方面。
在論文中,研究人員給出了用MNIST和多倫多人臉數據集 (TFD)訓練的模型所生成的樣本。
code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/aae/adversarial_autoencoder.py
paper:
Adversarial Autoencoders
Alireza Makhzani, Jonathon Shlens, Navdeep Jaitly, Ian Goodfellow, Brendan Frey
https://arxiv.org/abs/1511.05644>
BiGAN
全稱Bidirectional GAN,也就是雙向GAN。這種變體能學習反向的映射,也就是將數據投射回隱藏空間。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/bigan/bigan.py
Paper:
Adversarial Feature Learning
Jeff Donahue, Philipp Kr?henbühl, Trevor Darrell
https://arxiv.org/abs/1605.09782
BGAN
雖然簡稱和上一類變體只差個i,但這兩種GAN完全不同。BGAN的全稱是boundary-seeking GAN。
原版GAN不適用於離散數據,而BGAN用來自鑒別器的估計差異度量來計算生成樣本的重要性權重,為訓練生成器來提供策略梯度,因此可以用離散數據進行訓練。
BGAN里生成樣本的重要性權重和鑒別器的判定邊界緊密相關,因此叫做「尋找邊界的GAN」。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/bgan/bgan.py
Paper:
Boundary-Seeking Generative Adversarial Networks
R Devon Hjelm, Athul Paul Jacob, Tong Che, Adam Trischler, Kyunghyun Cho, Yoshua Bengio
https://arxiv.org/abs/1702.08431
CC-GAN
這種模型能用半監督學習的方法,修補圖像上缺失的部分。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/ccgan/ccgan.py
Paper:
Semi-Supervised Learning with Context-Conditional Generative Adversarial Networks
Emily Denton, Sam Gross, Rob Fergus
https://arxiv.org/abs/1611.06430
CGAN
條件式生成對抗網路,也就是conditional GAN,其中的生成器和鑒別器都以某種外部信息為條件,比如類別標籤或者其他形式的數據。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/cgan/cgan.py
Paper:
Conditional Generative Adversarial Nets
Mehdi Mirza, Simon Osindero
https://arxiv.org/abs/1411.1784
Context Encoder
這是一個修補圖像的卷積神經網路(CNN),能根據周圍像素來生成圖像上任意區域的內容。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/context_encoder/context_encoder.py
Paper:
Context Encoders: Feature Learning by Inpainting
Deepak Pathak, Philipp Krahenbuhl, Jeff Donahue, Trevor Darrell, Alexei A. Efros
https://arxiv.org/abs/1604.07379>
CoGAN
這類變體全名叫coupled GANs,也就是耦合對抗生成網路,其中包含一對GAN,將兩個生成模型前幾層、兩個辨別模型最後幾層的權重分別綁定起來,能學習多個域的圖像的聯合分布。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/cogan/cogan.py
Paper:
Coupled Generative Adversarial Networks
Ming-Yu Liu, Oncel Tuzel
https://arxiv.org/abs/1606.07536
CycleGAN
這個模型是加州大學伯克利分校的一項研究成果,可以在沒有成對訓練數據的情況下,實現圖像風格的轉換。
這些例子,你大概不陌生:
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/cyclegan/cyclegan.py
Paper:
Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks
Jun-Yan Zhu, Taesung Park, Phillip Isola, Alexei A. Efros
https://arxiv.org/abs/1703.10593>
論文原作者開源了Torch和PyTorch的實現代碼,詳情見項目主頁:
https://junyanz.github.io/CycleGAN/
DCGAN
深度卷積生成對抗網路模型是作為無監督學習的一種方法而提出的,GAN在其中是最大似然率技術的一種替代。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/dcgan/dcgan.py
Paper:
Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks
Alec Radford, Luke Metz, Soumith Chintala
https://arxiv.org/abs/1511.06434
DualGAN
這種變體能夠用兩組不同域的無標籤圖像來訓練圖像翻譯器,架構中的主要GAN學習將圖像從域U翻譯到域V,而它的對偶GAN學習一個相反的過程,形成一個閉環。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/dualgan/dualgan.py
Paper:
DualGAN: Unsupervised Dual Learning for Image-to-Image Translation
Zili Yi, Hao Zhang, Ping Tan, Minglun Gong
https://arxiv.org/abs/1704.02510>
GAN
對,就是Ian Goodfellow那個原版GAN。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/gan/gan.py
Paper:
Generative Adversarial Networks
Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, Yoshua Bengio
https://arxiv.org/abs/1406.2661
InfoGAN
這個變體是GAN的資訊理論擴展(information-theoretic extension),能完全無監督地分別學會不同表示。比如在MNIST數據集上,InfoGAN成功地分別學會了書寫風格和數字的形狀。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/infogan/infogan.py
Paper:
InfoGAN: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets
Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, Pieter Abbeel
https://arxiv.org/abs/1606.03657
LSGAN
最小平方GAN(Least Squares GAN)的提出,是為了解決GAN無監督學習訓練中梯度消失的問題,在鑒別器上使用了最小平方損失函數。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/lsgan/lsgan.py
Paper:
Least Squares Generative Adversarial Networks
Xudong Mao, Qing Li, Haoran Xie, Raymond Y.K. Lau, Zhen Wang, Stephen Paul Smolley
https://arxiv.org/abs/1611.04076
Pix2Pix
這個模型大家應該相當熟悉了。它和CycleGAN出自同一個伯克利團隊,是CGAN的一個應用案例,以整張圖像作為CGAN中的條件。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/pix2pix/pix2pix.py
Paper:
Image-to-Image Translation with Conditional Adversarial Networks
Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, Alexei A. Efros
https://arxiv.org/abs/1611.07004
Pix2Pix目前有開源的Torch、PyTorch、TensorFlow、Chainer、Keras模型,詳情見項目主頁:
https://phillipi.github.io/pix2pix/
SGAN
這個變體的全稱非常直白:半監督(Semi-Supervised)生成對抗網路。它通過強制讓辨別器輸出類別標籤,實現了GAN在半監督環境下的訓練。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/sgan/sgan.py
Paper:
Semi-Supervised Learning with Generative Adversarial Networks
Augustus Odena
https://arxiv.org/abs/1606.01583
WGAN
這種變體全稱Wasserstein GAN,在學習分布上使用了Wasserstein距離,也叫Earth-Mover距離。新模型提高了學習的穩定性,消除了模型崩潰等問題,並給出了在debug或搜索超參數時有參考意義的學習曲線。
本文所介紹repo中的WGAN實現,使用了DCGAN的生成器和辨別器。
Code:
https://github.com/eriklindernoren/Keras-GAN/blob/master/wgan/wgan.py
Paper:
Wasserstein GAN
Martin Arjovsky, Soumith Chintala, Léon Bottou
https://arxiv.org/abs/1701.07875
最後補充一點,作者為了讓沒有GPU的人也能測試這些實現,比較傾向於使用密集層(dense layer),只要在模型中能得出合理的結果,就不會去用卷積層。
—完—
加入社群
量子位AI社群13群開始招募啦,歡迎對AI感興趣的同學,加小助手微信qbitbot5入群;
此外,量子位專業細分群(自動駕駛、CV、NLP、機器學習等)正在招募,面向正在從事相關領域的工程師及研究人員。
進群請加小助手微信號qbitbot5,並務必備註相應群的關鍵詞~通過審核後我們將邀請進群。(專業群審核較嚴,敬請諒解)
誠摯招聘
量子位正在招募編輯/記者,工作地點在北京中關村。期待有才氣、有熱情的同學加入我們!相關細節,請在量子位公眾號(QbitAI)對話界面,回復「招聘」兩個字。
※AI大牛Jerry Kaplan:AGI?沒有技術和工程基礎
※科技部:推進人工智慧和實體經濟深度融合 壯大智能經濟
TAG:量子位 |