It's time to see whether the CNN really does hold up to our image reconstruction task at hand. We simply define a helper function that allows us to plot out a number of sampled examples that are generated from the test set and compare them to the original test inputs. Then, in the code cell that follows, we define a variable to hold the results of our model's inferences on the test set by using the .predict() method on our model object. This will generate a NumPy ndarray containing all of the decoded images for the inputs from the test set. Finally, we call the compare_outputs() function, using the test set and the decoded predictions thereof as arguments to visualize the results:
def compare_outputs(x_test, decoded_imgs=None, n=10):
plt.figure(figsize=(22, 5))
for i in range(n):
ax = plt.subplot(2, n, i+1)
...