August 2018
Intermediate to advanced
272 pages
7h 2m
English
An encoder (autoencoder without the decoder part) that consists of two convolutional layers and one fully connected layer is presented as follows. The parent autoencoder was trained on the MNIST dataset. Therefore, the network takes as input an image of size 28x28x1 and at latent space, encodes it to a 10-dimensional vector, one dimension for each class:
# Only half of the autoencoder changed for classification class CAE_CNN_Encoder(object): ...... def build_graph(self, img_size=28): 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]) self.__y_ = tf.placeholder("float", shape=[None, 10], name='Y') with ...