Neural Discrete Representation Learning [KOR]
Aaron van den Oord et al. / Neural Discrete Representation Learning / NIPS 2017
English version of this article is available.
1. Problem definition
์ค๋๋ Generative Model์ image, audio, video ๋ฑ ๋ง์ ๋ถ์ผ์์ ์ธ์์ ์ธ ์ฑ๊ณผ๋ฅผ ๋ด๊ณ ์๋ค. Generative model์ ๋ํ ๋ชจ๋ธ ์ค ํ๋๋ผ๊ณ ํ ์ ์๋ ๊ฒ์ด ๋ฐ๋ก Variational Auto Encoder(VAE)[1]์ด๋ค. VAE๋ data๋ฅผ ์ด๋ ํ latent space์ ๋งคํํ๊ณ , ๋งคํ๋ latent vector๋ฅผ ํตํด ์๋ก์ด ๋ฐ์ดํฐ๋ฅผ ์์ฑํ๋ ๋ชจ๋ธ์ด๋ค. ๊ธฐ์กด VAE๋ latent vector๊ฐ Gaussian distribution์ ๋ฐ๋ฅด๋๋ก ํ๊ณ , ํด๋น distribution์ ํ๊ท ๊ณผ ๋ถ์ฐ์ ์์ธกํจ์ผ๋ก์จ laten space๋ฅผ ์์ธกํ๊ฒ๋๋ค. ์ด๋ ๊ฒ ๊ตฌ์ฑ๋ latent space๋ก๋ถํฐ, ์ฐ๋ฆฌ๋ ์กด์ฌํ์ง ์์๋ ์๋ก์ด ๋ฐ์ดํฐ๋ฅผ ์์ฑํ ์ ์์๋ค.
2. Motivation
VAE์ latent vector๋ค์ continousํ ๊ฐ์ ๊ฐ์ง๋ค. ๋ค์ ๋งํด ์ํ๋ง ํ ์ ์๋ latent ๋ฒกํฐ์ ๊ฒฝ์ฐ์ ์๊ฐ ๋ฌดํํ๋ค๋ ๊ฒ์ด๋ค. ์ด๋ ๊ฒ ๋ฌดํํ ํฌ๊ธฐ์ latent space์ ๋ํด ๋ชจ๋ธ์ ํ์ตํ๋๊ฒ์ ๋งค์ฐ ์ด๋ ต๊ณ ๋นํจ์จ์ ์ด๋ค. ๋ฐ์ดํฐ๊ฐ ๋ฌดํํ space์ ์ด๋ป๊ฒ ๋งคํ๋ ์ง ์์ธกํ๊ธฐ ์ด๋ ค์ธ ๋ฟ๋๋ฌ ํนํ ๋งคํ๋ vector๋ค์ ํ๊ท ๊ณผ ๋ถ์ฐ์ ์ ์ดํ๊ธฐ ์ด๋ ต๊ธฐ ๋๋ฌธ์ด๋ค. VQ-VAE์ ๋ชจํฐ๋ฒ ์ด์ ์ ๋ฐ๋ก ์ฌ๊ธฐ์์ ์ถ๋ฐํ๋ค. ๋ง์ฝ ๋ชจ๋ธ์ ๋ฌดํํ ๊ณต๊ฐ์ latent space๊ฐ ์๋, ์ ํ๋ ํฌ๊ธฐ์(discrete) latent space์ ๋ํด ํ์ต์ํจ๋ค๋ฉด, ๋ฐ์ดํฐ๋ฅผ ๋ ์ฝ๊ณ ํจ์จ์ ์ผ๋ก ํ์ตํ ์ ์์ง ์์๊น? latent vector๊ฐ ๊ฐ์ง ์ ์๋ ๊ฒฝ์ฐ์ ์์ ๊ทธ ๊ฐ์ ์ ํํ๋ฉด, ์ฆ, ๋ค์๋งํด discrete latent space๋ฅผ ํ์ต์ํค๊ณ ๊ทธ๋ก๋ถํฐ ๋ฐ์ดํฐ๋ฅผ ์์ฑํด๋ณด๋ฉด ์ด๋จ๊น?
Related works
์ด์ ์๋ Discrete latent VAE ๋ฅผ ํ์ตํ๊ณ ์ ํ๋ ์๋๋ ๋ช ์์๋ค.
e.g. NVIL estimator[2], VIMCO[3]
ํ์ง๋ง ์ ๋ฐฉ๋ฒ๋ค์ ๋ชจ๋ ๊ธฐ์กด Gaussian ๋ถํฌ๋ฅผ ๋ฐ๋ฅด๋ continuous latent VAE ๋ชจ๋ธ์ ์ฑ๋ฅ์ ๋ฐ๋ผ์ก์ง ๋ชปํ๋ค. ๊ฒ๋ค๊ฐ ์ ๋ฐฉ๋ฒ๋ค์ MNIST์ ๊ฐ์ ๋งค์ฐ ์์ ๋ฐ์ดํฐ์ ์ผ๋ก ์คํ๋๊ฑฐ๋ ํ๊ฐ๋์์ผ๋ฉฐ, ๊ทธ ๋ชจ๋ธ์ ๊น์ด ์ญ์ ๋งค์ฐ ์์๋ค.
Idea
VQ-VAE์ ์์ด๋์ด๋ encoder์์ ๊ณ์ฐํ latent vector๋ฅผ ์นํ๋ ์ ์๋ ์ ํํ ๊ฐ์์ ๋ฒกํฐ๋ค์ ํ์ต ์ํด์ผ๋ก์จ discrete latent space๋ฅผ ๊ตฌ์ฑํ๊ฒ ๋ค๋ ๊ฒ์ด๋ค. ์ข ๋ ์ฝ๊ฒ ๋งํ์๋ฉด 1. ์ฐ์ ๋๋คํ discrete latent space๋ฅผ ์์ฑํ๋ค. 2. ๊ทธ๋ฆฌ๊ณ ์ด๊ฒ์ encoder output ๊ณผ ์ ๋งตํ๋๊ฒ๋ ํ์ต์ํจ๋ค.
ํ๋ง๋๋ก, ๋ฌดํํ ๊ณต๊ฐ์ distribution์ ์ ํํ ๊ณต๊ฐ์ distribution์ผ๋ก ๋งตํํ๋ non-linear layer๋ฅผ VAE์ encoder์ decoder ์ฌ์ด์ ์ถ๊ฐํ๊ฒ ๋ค๋ ๊ฒ์ด VQ-VAE์ ์์ด๋์ด์ด๋ค.
3. Method
Discrete Latent Space
๊ทธ๋ ๋ค๋ฉด discrete latent space๋ ์ด๋ป๊ฒ ๊ตฌ์ฑํด์ผ ํ ๊น? ๋ ผ๋ฌธ์ (K, D) ์ฐจ์์ embedding space๋ฅผ ๋๋ค์ผ๋ก ์์ฑํ๊ณ ์ด space๊ฐ encoder์ output์ ์ ๋ฐ์ํ๊ฒ๋ ํ์ต์ํด์ผ๋ก์จ discrete latent space๋ฅผ ๊ตฌ์ฑํ๋ค. ์ด์ encoder์ output ์ embedding space ์ค ์์ ๊ณผ ๊ฐ์ฅ ๊ฐ๊น์ด ๋ฒกํฐ๋ก ๋์ฒด๋์ด decoder์ ์ ๋ฌ๋๋ค. encoder ์์ํ์ธ posterior distribution์ ๋ค์๊ณผ ๊ฐ์ด ์ ์๋๋ค.
์ ์์์ z_e(x) ๋ encoder output์, e๋ embedding space๋ฅผ ์๋ฏธํ๋ค.
์ฌ๊ธฐ์ ํ๊ฐ์ง ์์๋ ๊ฒ์, ์ด๋ก ์ธํด posterior ๋ถํฌ๊ฐ deterministic ํด์ง๋ค๋ ๊ฒ์ด๋ค(latent z์ ๋ํด uniform prior๋ฅผ ์ ์ํ์ผ๋ฏ๋ก).
decoder์ ์ ๋ฌ๋ z_e(x) ๋ ์ต์ข ์ ์ผ๋ก ๋ค์๊ณผ ๊ฐ์ด ๋์ฒด๋๋ค.
Model Architecture
Forward
Encoder ๋ฅผ ํตํด input data ๋ก๋ถํฐ latent vector๋ฅผ ์ป๋๋ค.
D ์ฐจ์์ ๊ฐ์ง K๊ฐ์ latent embedding vector ์ค ์ป์ latent vector์ ๊ฐ์ฅ ์ ์ฌํ ๋ฒกํฐ๋ฅผ ๊ณ ๋ฅธ๋ค.
์ด๋ ๊ฒ ํ๋ ์ด์ ๋?(Reminder)
๊ธฐ์กด continuous ํ๋ latent vector๋ ๋์ฌ ์ ์๋ ๊ฒฐ๊ณผ๊ฐ ๋ฌดํํ์ง๋ง, ์์ ๊ฐ์ด ์ค๊ณํ๋ฉด ๊ฐ์ง ์ ์๋ latent vector์ ๊ฒฝ์ฐ์ ์๊ฐ discrete, ์ ํํด์ง๋ค. ๋ฐ๋ผ์ ํ์ต์ด ๋ณด๋ค controllable ํด์ง ๊ฒ์ด๋ผ๋ ๊ฒ ์ ์์ ๊ฐ์ค์ด๋ค.
์ด ์คํ ์ด ์ถ๊ฐ๋จ์ ๋ฐ๋ผ ํ์ต๋์ด์ผ ํ๋ ํ๋ผ๋ฏธํฐ๋ค์ encoder, decoder, ๊ทธ๋ฆฌ๊ณ embedding space E ๊ฐ ๋๋ค .
Decoder๋ฅผ ํตํด ๊ณ ๋ฅธ discrete latent vector๋ก๋ถํฐ data๋ฅผ ์์ฑํ๋ค.
Backward
Loss = reconstruction loss + Vector Quantisation(VQ) +commitment loss
reconstruction loss: ๊ธฐ์กด vae์ ๊ทธ reconstruction loss์ ๊ฐ๋ค. encoder์ decoder ํ์ต์ ์ํฅ์ ์ค๋ค.
VQ loss(=codebook loss): discrete latent space, ์ฆ embedding space ํ์ต์ ์ํ loss ๊ฐ. embedding space์ encoder output ๊ฐ์ L2์๋ฌ๋ก, ์ด๋ฅผ ํตํด embedding์ encoder output๊ณผ ๊ฐ๊น์์ง๋๋ก ํ์ต๋๋ค.
commiment loss: embedding space๋ encoder/decoder์ ๋ฌ๋ฆฌ 2์ฐจ์์ด๋ค(dimensionless). ๋ฐ๋ผ์ encoder/decoder ํ๋ผ๋ฏธํฐ์ ํ์ต ์๋๊ฐ ํ์ ํ ์ฐจ์ด๋ ์ ๋ฐ์ ์๋ค. encoder output์ด embedding space ํ์ต์ ์ํฅ์ ๋ฐ์ ๋น ๋ฅด๊ฒ ์ฆ๊ฐ/๋ฐ์ฐ ํ๋ ๊ฒ์ ๋ฐฉ์งํ๊ธฐ ์ํด, ์ ์๋ commitment loss๋ฅผ ์ธ๋ฒ์งธ ํญ์ผ๋ก ์ถ๊ฐํ๋ค.
์ Loss ๊ฐ์ backpropagation ํ ๋, Forward step 2๋ฒ '์ป์ latent vector์ ๊ฐ์ฅ ๊ฐ๊น์ด vector๋ฅผ embedding space๋ก ๋ถํฐ ๊ณ ๋ฅธ๋ค' ๋ผ๋ ์ฐ์ฐ์ ๋ํด์๋ gradient ๊ฐ์ ํ๋ฆด ์ ์๊ธฐ ๋๋ฌธ์(๋ฏธ๋ถ ๋ถ๊ฐ๋ฅ), ์ ์๋ decoder input์ gradient์ ๊ฐ์ encoder output ๊ฐ์ผ๋ก ๋จ์ ๋ณต์ฌํ๋ ํธ๋ฆญ์ ์ฌ์ฉํ๋ค.
we approximate the gradient similar to the straight-through estimator and just copy gradients from decoder input zq(x) to encoder output ze(x).
4. Experiment & Result
Experimental setup
๋ ผ๋ฌธ์ ๊ฐ์ฅ ๋จผ์ ๊ธฐ์กด continuous VAE ๋ชจ๋ธ, VIMCO ๋ชจ๋ธ, ๊ทธ๋ฆฌ๊ณ ๋ ผ๋ฌธ์ VQ-VAE ๋ชจ๋ธ์ ๋น๊ตํ๊ธฐ ์ํด, architecture๋ ๊ธฐ์กด standard VAE ๋ชจ๋ธ์ ๊ตฌ์กฐ๋ฅผ ๊ทธ๋๋ก ๊ฐ์ ธ๊ฐ๋, latent capacity ๋ง์ ๋ณ๊ฒฝํ์ฌ ํ์ต์ ์งํํ๋ค.
encoder๋ 2๊ฐ์ Conv2d(kerner_size=(4, 4), stride=2) ๋ก ์ด๋ฃจ์ด์ ธ ์์ผ๋ฉฐ ๋๊ฐ์ residual connection์ ๊ฐ์ง๋ค. ๋ชจ๋ ๋ ์ด์ด๋ 256 ์ฐจ์์ ๊ฐ์ง๋ค.
decoder๋ transposed CNN์ ์ฌ์ฉํ๋ค๋ ๊ฒ ์ ์ธ encoder์ ๋ชจ๋ ๋์ผํ ๊ตฌ์กฐ์ด๋ค.
Result
์์ ์คํ์ ํตํด ์ ์๋ VAE, VQ-VAE ๋ฐ VIMCO ๋ชจ๋ธ์ ๊ฐ๊ฐ 4.51bits/dim, 4.67bits/dim ๊ทธ๋ฆฌ๊ณ 5.14 bits/dim ์ ๊ฒฐ๊ณผ๋ฅผ ์ป์๋ค. (bits per dimension, ์ด๋ NLL loss๋ฅผ dimension์ผ๋ก ๋๋์ด์ค ๊ฐ์ด๋ค.)
Compute the negative log likelihood in base e, apply change of base for converting log base e to log base 2, then divide by the number of pixels (e.g. 3072 pixels for a 32x32 rgb image).
๋น๋ก VIMCO ๋ชจ๋ธ์ ์ฑ๋ฅ์ ๊น์ง๋ ๋ฏธ์น์ง ๋ชปํ์ง๋ง, ๊ทธ๋๋ discrete latent VAE ๋ชจ๋ธ๋ก์๋ ์ฒ์์ผ๋ก continuous VAE ๋ชจ๋ธ๊ณผ ์ ์ฌํ ์ฑ๋ฅ์ ์ป์ด๋๋ค๋ ์ ์์ ์ด ๋ ผ๋ฌธ์ novelty๊ฐ ์๋ค.
๋ ผ๋ฌธ์ Images, Audio, Video 3๊ฐ์ง์ ๋๋ฉ์ธ์ ๋ํด ๋ชจ๋ธ์ ์คํํ๊ณ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์๋ค. ๋ชจ๋ ๊ธฐ์กด VAE๋งํผ ์ข์ ์ฑ๊ณผ๋ฅผ ๋ณด์์ผ๋, ๊ทธ ์ค Audio ๋๋ฉ์ธ์ ๋ํ ๊ฒฐ๊ณผ๊ฐ ํฅ๋ฏธ๋กญ๋ค. ์ ์๋ Audio input์ ๋ํด์ latent vector์ ์ฐจ์์ด 64๋ฐฐ๋ ์ค์ด๋๋ฏ๋ก reconstruction ๊ณผ์ ์ด ์๋์ ์ผ๋ก ํ๋ค ๊ฒ์ด๋ผ ์์ํ์๋ค. ๊ทธ๋ฌ๋ ๊ฒฐ๊ณผ์ ์ผ๋ก๋ ๋ชจ๋ธ์ด audio์ content(๋ฐ์ฑํ ๋จ์ด๋ ๊ทธ ์๋ฏธ ๋ฑ e.g. 'ํ ์คํธ', '์๋ ')๋ค์ ์์ฃผ ์ reconstruction ํ๋ ๋์ , audio์ feature(๋ฐ์ฑ, ์์, ์์ญ๋ ๋ฑ e.g. ๋ชฉ์๋ฆฌ ํค, ์๋ฆฌ ๋๋ฎ์ด)๋ค๋ง ์กฐ๊ธ์ฉ ๋ณํ์ํค๋ ๊ฒ์ ํ์ธํ ์ ์์๋ค. ์ด๋ก ์ธํด ์ ์๋ VQ-VAE ๊ฐ ์๋ฆฌ์ ๊ณ ์ฐจ์์ ํน์ง๊ณผ ์ ์ฐจ์์ ํน์ง์ ์ ๋ถ๋ฆฌํ์ฌ ํ์ตํ ๋ฟ ์๋๋ผ ๊ทธ ์ค ๊ณ ์ฐจ์์ ํน์ง์ ์ฃผ๋ก encoding ํ๊ณ ์๋ค๊ณ ์ฃผ์ฅํ๋ค.
The VQ-VAE has learned a high-level abstract space that is invariant to low-level features and only encodes the content of the speech.
5. Conclusion
VQ-VAE ๋ VAE์ discrete latent space๋ฅผ ์ ์ฉํ ๋ํ์ ์ธ ๋ชจ๋ธ ์ค ํ๋๋ค. ๊ธฐ์กด VAE์ ๊ฑฐ์ ๋์ผํ ์ฑ๋ฅ์ ์ป์๋ค๋ ์ ์์ ์ฃผ๋ชฉํ ๋งํ๊ธฐ๋ ํ๊ณ , ๋ฌด์๋ณด๋ค ๊ฐ์ธ์ ์ธ ์๊ฒฌ์ผ๋ก๋ ํ์ต ํจ์จ์ด๋ ์์ ์ฑ ์ธก๋ฉด์์ ์ค์ ํ ์คํฌ์ ์ฌ์ฉ๋ ๋ ๋ฉ๋ฆฌํธ๊ฐ ์์ ๊ฒ์ด๋ผ ์๊ฐํ๋ค.
์์ฝ
Discrete latent space ๋ฅผ Codebook(=Embedding space) ์ ํตํด ๊ตฌํํ์๊ณ VAE์ ์ ์ฉ.
Discrete latent VAE model ๋ก์๋ ์ฒ์์ผ๋ก continuous VAEs ์ฑ๋ฅ์ ๊ฐ๊น์ด ๊ฒฐ๊ณผ๋ฅผ ์ป์ด๋.
VQ-VAE๋ฅผ ๋ค์ํ ๋๋ฉ์ธ์ ์ค์ ์ ์ฉํด๋ณด๊ณ ๋๋ ทํ ์ฑ์ทจ๋ฅผ ํ์ธ. ํนํ ์ค๋์ค ๋๋ฉ์ธ์์ high-level audio feature๋ค๋ง ์ธ์ฝ๋ฉ๋๋ ๊ฒฐ๊ณผ๋ฅผ ์ป์ด๋.
Take home message (์ค๋์ ๊ตํ)
VAE ๋ชจ๋ธ์ Latent Space๋ฅผ discrete ํ ๋ค ๊ทธ๊ฒ์ ์ ํ์ตํ๋ค๋ฉด ์ถฉ๋ถํ ์ฑ๋ฅ์ ์ป์ ์ ์์ผ๋ฉฐ, ๋์์ ํ์ต ํจ์จ์ ์ธก๋ฉด์์ ์ด์ ์ ์ป์ ์ ์๋ค.
Author / Reviewer information
Author
์ ์ค์ง (Yoonjin Chung)
Master Student, Graduate School of AI, KAIST
Reviewer
์ค๊ฐํ
์ฅํ์
์ดํ์ง
Reference & Additional materials
[1] Kingma, Diederik P and Welling, Max. Auto-Encoding Variational Bayes. In The 2nd International Conference on Learning Representations (ICLR), 2013.
[2] Andriy Mnih and Karol Gregor. Neural variational inference and learning in belief networks. arXiv preprint arXiv:1402.0030, 2014
[3] Andriy Mnih and Danilo Jimenez Rezende. Variational inference for monte carlo objectives. CoRR, abs/1602.06725, 2016.
Last updated
Was this helpful?