image thumbnail

Conditional VAE (Variational Auto Encoder) 条件付きVAE

version 1.1 (4.81 MB) by Kenta
This example shows how to create a conditional variational autoencoder (VAE) in MATLAB to generate digit images. 条件付き変分オートエンコーダによる手書き数字生成

231 Downloads

Updated 16 Apr 2020

View License

[English]
This example shows how to create a conditional variational autoencoder (VAE) in MATLAB to generate digit images. The VAE generates hand-drawn digits in the style of the MNIST data set. The difference from Variational Auto Encoder (VAE) is that conditional VAE can input the class label to generate, which enables to synthesize clearer images. A conditional GAN (Generative Adversarial Network) is also a variable to synthesize images. Synthesized images from VAE tend to be blurred since loss value becomes lower with such images. Using the GANs, the problem might be solved.
https://jp.mathworks.com/matlabcentral/fileexchange/74921-conditional-gan-generative-adversarial-network-with-mnist
[Japanese]
このデモでは、条件付き変分オートエンコーダを実装します。通常の変分オートエンコーダのちがいは、生成する画像のラベルを指定することができることです。これにより、よりきれいな画像を生成することができます。VAEの仕組み上、生成画像をぼやけさせたほうが損失関数の値が小さくなり、生成画像もあまりぼやけてしまう場合があります。下のリンクにあるGANを用いればよりよい結果が得られる可能性もあります。こちらも参考になれば幸いです。
https://jp.mathworks.com/matlabcentral/fileexchange/74921-conditional-gan-generative-adversarial-network-with-mnist

The conditional VAE in this demo was inspired by Kingma et al [1]. This live script was made based on the Matlab official document [2].
Reference
[1] Kingma, D. P., Mohamed, S., Rezende, D. J., & Welling, M. (2014). Semi-supervised learning with deep generative models. In Advances in neural information processing systems (pp. 3581-3589). http://papers.nips.cc/paper/5352-semi-supervised-learning-with-deep-generative-models
[2] Train Variational Autoencoder (VAE) to Generate Images (https://jp.mathworks.com/help/deeplearning/ug/train-a-variational-autoencoder-vae-to-generate-images.html;jsessionid=e6dfca3f40831afcce0ff7b71670)
[3] 山下隆義、イラストで学ぶ ディープラーニング 改訂第2版、KS情報科学専門書、2018年 (amazon)
[4] 巣籠 悠輔, 詳説ディープラーニング: 生成モデル編 Kindle版 (amazon)
[5] LeCun, Y., C. Cortes, and C. J. C. Burges. "The MNIST Database of Handwritten Digits." http://yann.lecun.com/exdb/mnist/.
[6] van der Maaten, Laurens, and Geoffrey Hinton. Visualizing Data using t-SNE. J. Machine Learning Research 9, 2008, pp. 2579–2605.
[7] Federico Errica, "Step-By-Step Derivation of SNE and t-SNE gradients"
http://pages.di.unipi.it/errica/assets/files/sne_tsne.pdf#search='StepByStep+Derivation+of+SNE+and+tSNE+gradients'
The illustrations in this script were obtained from the website below.
[8] かわいいフリーイラスト集 いらすとや https://www.irasutoya.com/
[9] Dr Stephen Odaibo: Variational Inference & Derivation of the Variational Autoencoder (VAE) Loss Function: A True Story
https://towardsdatascience.com/variational-inference-derivation-of-the-variational-autoencoder-vae-loss-function-a-true-story-3543a3dc67ee
[10] 高校数学の美しい物語:対数和不等式の証明と応用 https://mathtrain.jp/logsumineq

Cite As

Kenta (2021). Conditional VAE (Variational Auto Encoder) 条件付きVAE (https://www.mathworks.com/matlabcentral/fileexchange/74974-conditional-vae-variational-auto-encoder-vae), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!