class_docstr: An Autoencoder with deep fully-connected neural nets.
  
  Training Data: MNIST Handwritten Digits (28x28 images)
class_docstr_tok: ["An","Autoencoder","with","deep","fully-connected","neural","nets",".","Training","Data",":","MNIST","Handwritten","Digits","(","28x28","images",")"]
code: def save_imgs(self, epoch, X):
      r, c = 5, 5  # Grid size
      # Select a random half batch of images
      idx = np.random.randint(0, X.shape[0], r * c)
      imgs = X[idx]
      # Generate images and reshape to image shape
      gen_imgs = self.autoencoder.predict(imgs).reshape(
          (-1, self.img_rows, self.img_cols)
      )
  
      # Rescale images 0 - 1
      gen_imgs = 0.5 * gen_imgs + 0.5
  
      fig, axs = plt.subplots(r, c)
      plt.suptitle("Autoencoder")
      cnt = 0
      for i in range(r):
          for j in range(c):
              axs[i, j].imshow(gen_imgs[cnt, :, :], cmap="gray")
              axs[i, j].axis("off")
              cnt += 1
      fig.savefig("ae_%d.png" % epoch)
      plt.close()
  
file_path: ML-From-Scratch/mlfromscratch/unsupervised_learning/autoencoder.py
imports: from __future__ import print_function, division
  from sklearn import datasets
  import math
  import matplotlib.pyplot
  import numpy
  import progressbar
  from sklearn.datasets import fetch_mldata
  from mlfromscratch.deep_learning.optimizers import Adam
  from mlfromscratch.deep_learning.loss_functions import CrossEntropy, SquareLoss
  from mlfromscratch.deep_learning.layers import Dense, Dropout, Flatten, Activation, Reshape, BatchNormalization
  from mlfromscratch.deep_learning import NeuralNetwork
label_desc: Use image node_id 5 for calling the Autoencoder obj's underlying member method code with example usage: obj.save_imgs(epoch, X) without return types