We can construct a variational autoencoder in TensorFlow to see how it compares to it's simpler, standard autoencoder cousin. In this section, we'll be using the same MNIST dataset so that we can standardize our comparison across methods. Let's walk through how to construct a VAE by utilizing it to generate handwriting based on the MNIST dataset. Think of x as being the individual written characters and z as the latent features in each of the individual characters that we are trying to learn.
First, let's start with our imports:
import numpy as npimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data
As before, we can import the 'MNIST_data' directly from the TensorFlow library:
mnist = input_data.read_data_sets('MNIST_data', ...