Define the decoder network for reconstructing the image. It consists of three fully connected networks, as follows:
with tf.name_scope('Decoder'):
#masked digit capsule
v_j = tf.reshape(masked_v, shape=(batch_size, -1))
#first fully connected layer
fc1 = tf.contrib.layers.fully_connected(v_j, num_outputs=512)
#second fully connected layer
fc2 = tf.contrib.layers.fully_connected(fc1, num_outputs=1024)
#reconstructed image
reconstructed_image = tf.contrib.layers.fully_connected(fc2, num_outputs=784, activation_fn=tf.sigmoid)