Professional Documents
Culture Documents
Deep Learning - GAN
Deep Learning - GAN
– GAN
𝑛
Assume Φ = 𝝓𝑖 𝑖=1 is an orthonormal set, 𝒙 is a vector.
Decomposition : 𝑐𝑖 = 𝒙, 𝝓𝑖 for 𝑖 = 1,2, … , 𝑛.
𝑐𝑖 the amount of projection of x in the direction of 𝝓𝑖 .
𝒄 = Φ𝑡 𝒙 is the decomposition of vector x.
Synthesis : 𝒙
= σ𝑛𝑖=1 𝑐𝑖 𝝓𝑖 = ΦΦ𝑡 𝒙.
𝒙 is the reconstruction of 𝒙 with reconstruction loss 𝐿2 (𝒙,
𝒙).
If Φ is a basis, 𝐿2 𝒙,
𝒙 = 0.
ANALYSIS
If Φ = 𝝓𝑖 𝑛𝑖=1 is a orthonormal vectors in a vector
space, and 𝒙 is a vector in the vector space.
𝑐𝑖 = 𝒙, 𝝓𝑖 for 𝑖 = 1,2, … , 𝑛.
𝑐𝑖 is the projection of vector x on the direction of 𝝓𝑖 .
Decomposition of the vector 𝐱 in the subspace
𝒄 = Φ𝑡 𝒙 = 𝝓1 𝝓2 … 𝝓𝑛 𝑡 𝒙
𝑐1 = 𝝓1 𝑡 𝒙
𝑐1 𝝓1 𝑡 𝝓1 𝑡 𝒙 𝝓1
⋮ = ⋮ 𝒙= ⋮
𝒄
𝑐𝑛 𝝓𝑛 𝑡 𝝓𝑛 𝑡 𝒙 𝒙
⋮
𝑐𝑖 = 𝝓𝑖 𝑡 𝒙 = 𝒙, 𝝓𝑖 ⋮
Φ as an analysis network
Φ𝑡
𝝓𝑖 connection weights of neuron i
SYNTHESIS
𝑐1
= σ𝑛𝑖=1 𝑐𝑖 𝝓𝑖 = 𝝓1 𝝓2 … 𝝓𝑛
𝒙 ⋮
𝑐𝑛
𝑐1 𝝓1
𝑡
= Φ𝒄 = ΦΦ 𝒙.
𝝓1
Reconstruction of the vector 𝒙 in
linear subspace spanned by Φ. 𝒄
𝒙
Reconstruction error: 𝐿2 (𝒙, 𝒙
). ⋮ ⋮
When Φ is a basis of the vector
space, 𝐿2 𝒙, 𝒙
= 0.
Φ
𝒄 is a representation of 𝒙.
analysis synthesis
𝒙 𝒄
𝒙
Φ𝑡 Φ
EXAMPLE: DFT / IDFT
Discriminator Generator
𝑥 𝑧 𝑥
D G + 𝐿2 (𝑥 − 𝑥)
−
Generator
(synthesis)
noise
Xfake
z G 𝐷(𝑋)
D
Xreal
Real Discriminator
(analysis)
DISCRIMINATOR
Binary Classifier
Tell if an object is of
a specific type or not
Positive/negative samples
e.g. CNN
label Cross
0/1 Entropy
FNN GENERATOR
784 28 x 28
noise X
z
Y
Fully connected
DCNN GENERATOR
16384 8x8x256
z G Xfake
DCNN
up pooling
Layer Operation Input Output
z 16x16x256
Fully Connected
+
Xreal
+ +
+
border +
- Xfake
- border
Xfake -
attackers Xfake
DISCUSSIONS
Discriminator is a binary classifier
with positive samples ONLY.
Negative samples are produced by
Generator. defenders
Xreal +
If Generator is not good enough, +
+ +
z
Xfake
G
(0,1)
c D
Condition: 7 Real
photos
Xreal
Change z
noise
z
G
c
Change
c condition 2
Label as condition
Cited from C-GAN by M Mirza
C-GAN EXAMPLE – AUTO TAGGING
Xfake
z G
c D
z
creek,
lake,
c G waters,
river
condition
condition
D使用PatchGAN: 判斷任意NxN的patch為real/fake
減小Xreal空間,且有更多正樣本
DOMAIN TRANSFORMATION
Auto-Encoder
Variational Auto-Encoder (VAE)
GAN/cGAN Transformer
Star GAN
AUTO-ENCODER, AE (TRANSFORMATION)
Transformation Encoder-decoder
𝑋 𝑧 Unet/ResNet
D G
Learn transformation
𝑌෨
Need paired data
−𝐿𝑝 (𝑌෨ − 𝑌) 𝑋𝑖 , 𝑌𝑖
𝑌 min 𝐿1 (𝑌 − 𝑌)
෨
Example
Gray-to-color
VARIATIONAL AUTO-ENCODER
𝝁 𝒛
+ G
𝑋
D 𝑌෨
×
𝝈 −𝐿𝑝 (𝑌෨ − 𝑌)
𝑌
𝑁(0,1) ~
𝑋
D G 𝑌෨
cGAN (conditional)
Need paired data
D T= 𝑋𝑖 , 𝑌𝑖
Conditional Real
Could add L1 loss
photos
GAN 𝑌
CYCLE GAN
𝑌𝑋 𝑋 𝑌𝑓𝑎𝑘𝑒 = 𝐹(𝑋)
𝑋 X-
X- Domain F Domain
F
𝑋෨
෨
𝐿CYC (𝑋 − 𝑋) + G Y-
𝑌𝑟𝑒𝑎𝑙
− DY
Domain 𝐿𝐺𝐴𝑁 (𝐷𝑌 , 𝐹)
D G 0/1
If using CycleGAN
Multiple transformer
A lot of computations
Not flexible
STARGAN
𝑋
D G
𝑐: 𝑌𝑓𝑎𝑘𝑒
Black
hair D:
D real/fake
𝑌𝑟𝑒𝑎𝑙
Y domain
𝐶𝑙𝑎𝑠𝑠𝑖𝑓𝑖𝑒𝑟:
Dy Is black hair
෩ or not
X
.
෨
𝐿𝑟𝑒𝑐 (𝑋 − 𝑋) G D
.
.
𝑐: Blond hair
STARGAN EXAMPLE