August 2018
Intermediate to advanced
272 pages
7h 2m
English
The following TensorFlow code will build a convolutional autoencoder model for the MNIST dataset. This first part of the code will construct the graph of your model, the encoder and the decoder. In the code, we highlight the part of the model whose output will be our latent vector:
class CAE_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