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 train(self, n_epochs, batch_size=128, save_interval=50):
      mnist = fetch_mldata("MNIST original")
  
      X = mnist.data
      y = mnist.target
  
      # Rescale [-1, 1]
      X = (X.astype(np.float32) - 127.5) / 127.5
  
      for epoch in range(n_epochs):
          # Select a random half batch of images
          idx = np.random.randint(0, X.shape[0], batch_size)
          imgs = X[idx]
  
          # Train the Autoencoder
          loss, _ = self.autoencoder.train_on_batch(imgs, imgs)
  
          # Display the progress
          print("%d [D loss: %f]" % (epoch, loss))
  
          # If at save interval => save generated image samples
          if epoch % save_interval == 0:
              self.save_imgs(epoch, X)
  
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 4 for calling the Autoencoder obj's underlying member method code with example usage: obj.train(n_epochs, batch_size, save_interval) without return types