August 2018
Intermediate to advanced
272 pages
7h 2m
English
After the VAE model is trained, we can chop off its decoder part and use this as a generator to generate new data for us. It will work by feeding it new latent vectors that come from a unit Gaussian distribution.
We present in TensorFlow the code responsible for build this generating VAE graph as follows:
class VAE_CNN_GEN(object): def __init__(self, img_size=28, latent_size=20): self.__x = tf.placeholder(tf.float32, shape=[None, latent_size], name='LATENT_IN') with tf.name_scope('DECODER'): # Linear layer self.__z_develop = tf.layers.dense(inputs=self.__x, units=7 * 7 * 32, activation=None, name="z_matrix") self.__z_develop_act = tf.nn.relu(tf.reshape(self.__z_develop, [tf.shape(self.__x)[0], 7, 7, 32])) # DECONV1 self.__conv_t2_out_act ...