We proceed with the recipe as follows:
- The first step is importing all the necessary modules:
import tensorflow as tfimport numpy as npfrom tensorflow.examples.tutorials.mnist import input_dataimport matplotlib.pyplot as plt%matplotlib inline
- Load the dataset:
mnist = input_data.read_data_sets("MNIST_data/")trX, trY, teX, teY = mnist.train.images, mnist.train.labels, mnist.test.images, mnist.test.labels
- Next, we define the class, StackedAutoencoder . The class __init__ method contains a list containing a number of neurons in each autoencoder, starting from the first input autoencoder and the learning rate. As each layer will have different dimensions for input and output, we choose a dictionary data structure to represent ...