August 2018
Intermediate to advanced
272 pages
7h 2m
English
We can now piece together everything and present TensorFlow code that will build a convolutional VAE for the MNIST dataset. We create a class for our VAE model and place the model in the __init__ method. The first part is the encoder of our model made up of two conv layers:
class VAE_CNN(object): def __init__(self, img_size=28, latent_size=20): self.__x = tf.placeholder(tf.float32, shape=[None, img_size * img_size], name='IMAGE_IN') self.__x_image = tf.reshape(self.__x, [-1, img_size, img_size, 1]) with tf.name_scope('ENCODER'): ##### ENCODER # CONV1: Input 28x28x1 after CONV 5x5 P:2 S:2 H_out: 1 + (28+4-5)/2 = 14, W_out= 1 + (28+4-5)/2 = 14 self.__conv1_act = tf.layers.conv2d(inputs=self.__x_image, ...Read now
Unlock full access