What are Variational Autoencoders? A simple explanation

Dominic Monn
2 min readJun 27, 2017

--

In my last post, I showed you how to use Deep Convolutional GANs to generate human faces. In this post, I’ll explain why using a plain DCGAN isn’t optimal for this and why Variational Autoencoders — VAEs for short — are the better choice.

GANs are awesome! But as we have seen in my previous post, they still generate pretty random results. I gave my DCGAN a huge dataset of celebrity faces, which led it to generate new, but random faces — which is fun for a research project, but quite useless for anything in production.
What if I want to generate a specific face — for example, one with black hair, green eyes and a blonde mustache? What if I want to generate specific digits or letters? I’m not able to configure a GAN to take these parameters into account. This is where VAEs are coming into play.

Illustration of a VAE

Just like regular Autoencoders, VAEs try to reconstruct output from input and consist of an encoder and a decoder, which are encoding and decoding the data. The encoder outputs a compressed representation of the output data. The decoder then learns to reconstruct the initial input data by taking this compressed representation as input data. This way, you can use the decoder as a generative model which is able to generate specific features — such as specific digits or letters.

I have found a simple implementation example on the Keras blog. They build a sample VAE to generate handwritten digits based on the MNIST dataset. If you are interested in building a VAE yourself, definitely check it out!

Use Cases

But where exactly can we use this type of neural network? Because VAEs are much more flexible and customizable in their generation behavior than GANs, VAEs are suitable for art generation of any kind.

Carl Doersch briefly talks about the possibility of generating 3D models of plants to cultivate video-game forests in his paper and the blog “Machine Learning Insights” created a small tool to generate pixel art of a video game character just recently.

Think about it: With the ability to generate customizable art of any kind you can generate video game characters and 3D models of trees — but also logos, drawings, personalized music and so much more! The possibilities are endless.

So there you have it! VAEs are an incredible tool when it comes to art generation of any kind and are possibly a tool to transform the work of creatives in the future. A VAE could potentially become a graphic designer’s best friend when it comes to inspiration and prototyping.

Thanks for reading my article! Let me know if I got anything wrong or if you want to discuss the topic a little bit further. I’m always up for a constructive discussion!

--

--