본문 바로가기
Deep Learning

GAN(Generative Adversarial Nets)을 파악해보자!

by Think_why 2019. 10. 15.

Ian J. Goodfellow(유명하신 좋은 친구님)의 GAN 논문

https://papers.nips.cc/paper/5423-generative-adversarial-nets.pdf

 

가장 이해하기 쉬운 설명은 역시 예시이다. 

좋은 친구님이 설명을 위해 예시로 들었던 내용이 기가 막힌다.

 

"위조범(G)이 위조 지폐(Fake)를 만들고, 형사(D)가 지폐(Real)와 위조 지폐(Fake)를 구분하도록

경쟁적으로 훈련시키면, D가 구분 못할 정도로 G가 Fake를 잘 만들어낸다." 라는 예시이다.

 

이제 Abstract를 살펴보자. 영어 실력은 부족하지만 최대한 해석을 해보았다.

 

[Abstract] 

We propose a new framework for estimating generative models via an adversarial process,

적대적인 과정을 통해 생성 모델을 추정하기 위한 새로운 프레임워크를 제안합니다.

in which we simultaneously train two models: a generative model Gthat captures the data distribution, 

여기선 두 가지 모델을 동시에 훈련시킵니다 : 데이터 분포를 알아내는 생성 모델 G와,

a discriminative model D that estimates the probability that a sample came from the training data rather than G.

훈련 데이터(G라기 보다는)로부터 나온 확률을 예측하는 분류 모델 D입니다.

The training procedure for G is to maximize the probability of D making a mistake. 

G의 훈련 과정은 D가 실수하는 확률을 최대화하는 것입니다.

This framework corresponds to a minimax two-player game. 

이 프레임워크는 Minimax 2인 게임(의사 결정 게임 알고리즘)에 해당합니다.

In the space of arbitraryfunctions G and D, a unique solution exists, 

임의의 함수 G와 D의 사이에는, 특별한 해결책이 존재하는데요,

with G recovering the training datadistribution and D equal to 1/2 everywhere. 

G는 훈련 데이터 분포로 복구하고, D는 모든 곳에서 1/2로 동일해지는 것입니다.

In the case where G and D are definedby multilayer perceptrons, the entire system can be trained with backpropagation. 

G와 D가 MLP로 정의되는 경우, 전체 시스템은 역전파법으로 훈련이 가능합니다.

There is no need for any Markov chains or unrolled approximate inference networks during either training or generation of samples. 

더 이상 훈련 또는 샘플 생성에 Markov chain이나 unrolled approximate inference networks가 필요하지 않다. 

Experiments demonstratethe potential of the framework through qualitative and quantitative evaluation ofthe generated samples. 

실험은 생성된 샘플의 정성적, 정량적 평가를 통해 프레임워크의 잠재력을 증명합니다.

 

중요한 키워드는 적대적인 모델(분류 모델 G vs 생성 모델 D), MLP, 데이터 분포인 것 같다.

 

논문 내용 중,

3. Adversarial nets에 적혀있는 D와 G의 two-player minimax game with value function V(G,D)을 보고,

사용된 수식과 내용을 간략하게 정리해보았다.

 

 

이는 1) G가 수식 V를 최소화 해야하고, 2) D는 수식 V를 최대화하기 위한 방법을 찾는 것이 목적이다.

 

1) G가 수식 V를 최소화하려 한다. log(D(x))는 관여할 수 없기 때문에,  log(1-D(G(x)))를 최소화하는 방식을 채택한다.

여기서, log(1-D(G(x)))를 최소화하기 보다, D(G(z))를 최대화하도록 G를 훈련시키는 방식이 가능하다고 설명한다.

2) D는 수식 V를 최대화하려 한다. log(D(x))에서 D(x)를 최대화하도록 D를 훈련시키는 방식이다. 

 

4. Theoretical Results를 보면 나오는 그림과 설명을 간략하게 정리해보았다.

 

 

이제 이것을 학습할 코드를 위해서 훈련 방식을 도식화한 그림을 만들어 보았다.

 

D를 훈련시키는 방식 : D(x)를 최대화

 

 

G를 훈련시키는 방식 : D(G(z))를 최대화

 

 

Noise data는 latent z vector라고 보통 표현한다.

이를 이용해서 Pytorch로 구현한 GAN 코드는 내 github에 있다. 

 

https://github.com/wlstyql/Pytorch/tree/master/GAN

 

wlstyql/Pytorch

Contribute to wlstyql/Pytorch development by creating an account on GitHub.

github.com

(2019.10.21)

Github에서 ipynb 오류가 자주 나서, nbviewer 추가

https://nbviewer.jupyter.org/github/wlstyql/Pytorch/tree/master/GAN/

 

Jupyter Notebook Viewer

 

nbviewer.jupyter.org

 

728x90

'Deep Learning' 카테고리의 다른 글

if(kakao) dev 2019 - README.ocr 정리  (0) 2019.10.26
Kaggle - Denoising Dirty Documents  (0) 2019.10.15
딥러닝 전문가와의 대화  (0) 2019.10.15
Kaggle 입문기  (0) 2019.10.15
개인 Github 주소  (0) 2019.10.15

댓글