Reshape and get the original image by using the following code:
original_image = tf.reshape(x, shape=(batch_size, -1))
Compute the mean of the squared difference between the reconstructed and the original image:
squared = tf.square(reconstructed_image - original_image)
Compute the reconstruction loss:
reconstruction_loss = tf.reduce_mean(squared)