VQ-VAE-1
VAE에서 latent space를 discrete representation으로 나타내는 방법이다. 일종의 dictionary라고 볼 수도 있는데, continuous feature를 사전에 정해진 개수만큼 trainable한 dictionary feature로 mapping한다. Motivation은 다음과 같다.
- Discrete representations are a more natural fit for many domains (vision, nlp, speech)
- Good generator and useful latent features
- To prevent “posterior collapse” occurred by powerful decoder


Forward pass 단계는 다음과 같다.
1) Encoder 통과 후 latent ze(x) 획득
2) ze(x)와 dictionary의 k개의 embedding (e) 간의 거리를 비교해서 거리가 가장 짧은 embedding를 획득
3) 획득한 embedding을 input (zq(x))으로 decoder 연산
Backward pass에서 미분이 불가능한 연산은 (dictionary에서 embedding을 찾는 과정) 생략하고 dloss/dzq(x)를 encoder로 직접 전달한다. (straight-through gradient estimation)
위 loss에서 첫 번째 term은 input x를 reconstruction 하는 과정, 두 번째 term은 encoder를 fix하고 dictionary만 update하여 encoder output과 fit하도록 하는 과정, 마지막 term은 encoder output이 발산하지 않도록 dictionary를 fix하고 fit하는 과정이다.
Questions
1. k개 category의 데이터만 생성할 수 있는거 아닌가요?
: 예를 들어 encoding 후 latent space의 shape (width, height, channel)이 (8, 8, 10)고 k가 512, dictionary의 feature dim이 10이라면 decoder가 생성할 수 있는 데이터 종류는 512^(8 x 8)이다. 즉, 각각의 (width, height) 쌍에 대하여 512개 중 최소 거리의 embedding을 찾는 것이다. (위 그림에서 q(z|x) 네모 박스의 index가 의미하는 것이 바로 그것이다)
2. 어떻게 powerful autoregressive prior를 VQ-VAE와 함께 사용하죠?
: 학습 후에는 encoder를 떼어내고 autoregressive prior가 생성한 latent z를 이용하여 dictionary에 mapping한다. 이때의 latent z는 global structure를 반영한다.
References
[1] A. Oord et al., Neural Discrete Representation Learning, NIPS 2017