Tensorflow 및 Pytorch의 변형 자동 인코더에 대한 참조 구현.
Pytorch 버전을 추천합니다. 여기에는보다 표현적인 변이 패밀리의 예, 역 자기 회귀 흐름의 예가 포함됩니다.
변형 추론은 모델에 이사화 된 MNIST 필기 자리 이미지에 맞는 데 사용됩니다. 추론 네트워크 (인코더)는 추론을 상각하고 데이터 포인트에서 매개 변수를 공유하는 데 사용됩니다. 가능성은 생성 네트워크 (디코더)에 의해 매개 변수화됩니다.
블로그 게시물 : https://jaan.io/what-is-variational-autoencoder-vae-tutorial/
(Anaconda 환경은 environment-jax.yml )
중요 샘플링은 Hugo Larochelle의 이진 MNIST 데이터 세트의 한계 가능성을 추정하는 데 사용됩니다. 테스트 세트의 마지막 한계 가능성은 -97.10 Nats는 게시 된 숫자와 비슷합니다.
$ python train_variational_autoencoder_pytorch.py --variational mean-field --use_gpu --data_dir $DAT --max_iterations 30000 --log_interval 10000
Step 0 Train ELBO estimate: -558.027 Validation ELBO estimate: -384.432 Validation log p(x) estimate: -355.430 Speed: 2.72e+06 examples/s
Step 10000 Train ELBO estimate: -111.323 Validation ELBO estimate: -109.048 Validation log p(x) estimate: -103.746 Speed: 2.64e+04 examples/s
Step 20000 Train ELBO estimate: -103.013 Validation ELBO estimate: -107.655 Validation log p(x) estimate: -101.275 Speed: 2.63e+04 examples/s
Step 29999 Test ELBO estimate: -106.642 Test log p(x) estimate: -100.309
Total time: 2.49 minutes
비 평균 필드,보다 표현적인 변동성 후방 근사치 (역자토 회귀 흐름, https://arxiv.org/abs/1606.04934)를 사용하여 테스트 한계 로그-크게 -95.33 NATS로 향상됩니다.
$ python train_variational_autoencoder_pytorch.py --variational flow
step: 0 train elbo: -578.35
step: 0 valid elbo: -407.06 valid log p(x): -367.88
step: 10000 train elbo: -106.63
step: 10000 valid elbo: -110.12 valid log p(x): -104.00
step: 20000 train elbo: -101.51
step: 20000 valid elbo: -105.02 valid log p(x): -99.11
step: 30000 train elbo: -98.70
step: 30000 valid elbo: -103.76 valid log p(x): -97.71
JAX 사용 (Anaconda 환경은 environment-jax.yml 에 있습니다)은 Pytorch보다 3 배의 속도를 얻습니다.
$ python train_variational_autoencoder_jax.py --variational mean-field
Step 0 Train ELBO estimate: -566.059 Validation ELBO estimate: -565.755 Validation log p(x) estimate: -557.914 Speed: 2.56e+11 examples/s
Step 10000 Train ELBO estimate: -98.560 Validation ELBO estimate: -105.725 Validation log p(x) estimate: -98.973 Speed: 7.03e+04 examples/s
Step 20000 Train ELBO estimate: -109.794 Validation ELBO estimate: -105.756 Validation log p(x) estimate: -97.914 Speed: 4.26e+04 examples/s
Step 29999 Test ELBO estimate: -104.867 Test log p(x) estimate: -96.716
Total time: 0.810 minutes
Jax의 역자 가관 흐름 :
$ python train_variational_autoencoder_jax.py --variational flow
Step 0 Train ELBO estimate: -727.404 Validation ELBO estimate: -726.977 Validation log p(x) estimate: -713.389 Speed: 2.56e+11 examples/s
Step 10000 Train ELBO estimate: -100.093 Validation ELBO estimate: -106.985 Validation log p(x) estimate: -99.565 Speed: 2.57e+04 examples/s
Step 20000 Train ELBO estimate: -113.073 Validation ELBO estimate: -108.057 Validation log p(x) estimate: -98.841 Speed: 3.37e+04 examples/s
Step 29999 Test ELBO estimate: -106.803 Test log p(x) estimate: -97.620
Total time: 2.350 minutes
(평균 필드와 역 자기 회귀 흐름의 차이는 몇 가지 요인으로 인한 것일 수 있으며, 주요한은 구현에 대한 컨볼 루션이 부족한 것일 수 있습니다. 잔류 블록은 https://arxiv.org/pdf/1606.04934.pdf에서 사용됩니다.
python train_variational_autoencoder_tensorflow.py 를 실행하십시오convert -delay 20 -loop 0 *.jpg latent-space.gif 생성하십시오.