GAN (Generative Adversarial Networks

20  Download (0)

Full text
(1)

Generative

Adversarial

Network

Wanho Choi

(wanochoi.com)

(2)

“GAN is the

most interesting idea in the last ten years in machine learning.”

(3)

Who Invented

(4)
(5)

GAN

Generative Adversarial Network

Generative: It is a generative model. (generation = making a plausible fake)

Adversarial: G and D compete against each other improving each other.

Network: Both G and D use deep neural networks.

Two models fighting against each other

would be able to co-train through plain old back-propagation.

decision : real or fake fake data real data

D

iscriminator (discriminative model)

G

enerator (generative model)

(6)

Goodfellow’s Metaphor

지폐위조범(Generator)과 경찰(Discriminator)은 서로 적대적인 경쟁 관계이다.

위조지폐범은 최대한 진짜같은 위조지폐를 만들어서 경찰을 속이기 위해 노력한다. (생성)

경찰은 위조 지폐인지 아닌지를 판별하기 위해 노력한다. (분류)

이러한 과정을 조금씩 오랫동안 거치면.. 위조지폐범은 진짜와 구별하기 어려운 위조지폐를 만들어 내는 능력을 가지게 된다. (경찰의 real/fake 구별 확률이 0.5로 수렴한다.) Generator (생성 모델) Discriminator (분류 모델) fake data real data decision real / fake

(7)

Generator

(=생성 네트워크)는 (=랜덤 변수)를 입력으로 받는다.

개념적으로 는 latent features를 나타낸다. (즉, : latent vector) (ex) 색상, 형태, …

하지만 GAN은 학습의 결과로 인해 를 얻게될 뿐, 에 대해 별다른 제어를 하지는 않는다.

만약 latent space 상에서의 의 의미를 알고 싶다면 학습이 끝난 후에 를 점차적으로 변화시키면서 출력 데이터가 어떻게 변하는지를 관찰하면 된다.

G

z

z

z

z

z

z

z

Generator (생성 모델)

̂x

z ∼ P(Z)

̂x = G(z)

: fake data

(8)

Exploring the GAN’s Latent Space

왼쪽을 바라보는 얼굴을 만들어 내는 z 오른쪽을 바라보는 얼굴을 만들어 내는 z interpolation

(9)

Arithmetic Operation

(10)

Modeling Probability Distribution

어떠한 확률 변수가 특정 확률 분포를 따른다.

이 확률 변수의 확률 분포를 알고 있다.

이 확률 변수의 기대값, 분산, 표준편차 등의 통계적 특성을 분석할 수 있다.

주어진 확률분포를 따르도록 데이터를 임의 생성한 데이터는 실측 데이터와 유사한 값을 가진다.

GAN: 학습 데이터의 확률 분포를 모델링할 수 있으면, 그럴듯한 가짜 데이터를 만들어낼 수 있다. https://dreamgonfly.github.io/2018/03/17/gan-explained.html Generator는 단순한 분포를 복잡한 분포로 매핑하는 함수이다.

latent space: z-vector가 존재하는 공간. latent space dimension은 제한이 없지만,

(11)

Modeling Probability Distribution

어떠한 확률 변수가 특정 확률 분포를 따른다.

이 확률 변수의 확률 분포를 알고 있다.

이 확률 변수의 기대값, 분산, 표준편차 등의 통계적 특성을 분석할 수 있다.

주어진 확률분포를 따르도록 데이터를 임의 생성한 데이터는 실측 데이터와 유사한 값을 가진다.

GAN: 학습 데이터의 확률 분포를 모델링할 수 있으면, 그럴듯한 가짜 데이터를 만들어낼 수 있다. noise ~ normal distribution

G

fake data real data

D

real/fake classification gradient comparison https://poloclub.github.io/ganlab/

(12)

https://www.youtube.com/watch?time_continue=10&v=kSLJriaOumA

(13)

GAN Pseudo Code

R = NextBatch() # real data

Z = GenerateNoise() # latent space

F = Generator( Z ) # fake data

D_fake = Discriminator( F ) D_real = Discriminator( R )

D_cost = -SUM( log( D_real ) + log( 1 - D_fake ) ) G_cost = -SUM( log( D_fake ) )

Minimize( D_cost ) Minimize( G_cost )

(14)

Decision Function: y=D(x)

R = NextBatch() # real data

Z = GenerateNoise() # latent space

F = Generator( Z ) # fake data

D_fake = Discriminator( F ) D_real = Discriminator( R )

D_cost = -SUM( log( D_real ) + log( 1 - D_fake ) ) G_cost = -SUM( log( D_fake ) )

Minimize( D_cost ) Minimize( G_cost )

A function quantifying a decision

It returns y close to 0 as x is judged to be fake.

It returns y close to 1 as x is judged to be real. Decision Function fake data 0.0 Decision Function real data 1.0

(15)

Recap: Logarithm

−∞ ≈ log(0 + ϵ) 0 ≈ log(1 − ϵ)

y = log x

(0.0 < x < 1.0)

It gets closer to 0 as it gets closer to 1.

It gets exponentially negative infinity as it gets closer to 0.

(16)

Objective Function (1/2)

R = NextBatch() # real data

Z = GenerateNoise() # latent space

F = Generator( Z ) # fake data

D_fake = Discriminator( F ) D_real = Discriminator( R )

D_cost = -SUM( log( D_real ) + log( 1 - D_fake ) ) G_cost = -SUM( log( D_fake ) )

Minimize( D_cost ) Minimize( G_cost )

From the generator’s point of view

D(F) should have a value close to 1.0.

Therefore, we can define the loss function as follows.

We should maximize.

Thus, we should minimize the minus of it.

log(D(F))

(17)

Objective Function (2/2)

R = NextBatch() # real data

Z = GenerateNoise() # latent space

F = Generator( Z ) # fake data

D_fake = Discriminator( F ) D_real = Discriminator( R )

D_cost = -SUM( log( D_real ) + log( 1 - D_fake ) ) G_cost = -SUM( log( D_fake ) )

Minimize( D_cost ) Minimize( G_cost )

From the discriminator’s point of view

D(R) should have a value close to 1.0.

D(F) should have a value close to 0.0.

Therefore, we can define the loss function as follows.

We should maximize.

Thus, we should minimize the minus of it.

log(D(R)) + log(1 − D(F))

(18)

How To Train GAN

decision : real or fake fake data real data

D

iscriminator (discriminative model)

G

enerator

(generative model) combined network

To train the discriminator network

D( real_data ) ⟶ 1.0

D( fake_data ) ⟶ 0.0

To train the combined network: C( x ) = D( G( x ) )

(19)

Mode Collapsing Problem

(20)

Figure

Updating...

References

Related subjects :