We proceed with the recipe as follows:
- As always, the first step is to import all the necessary modules:
import tensorflow as tfimport numpy as npfrom tensorflow.examples.tutorials.mnist import input_dataimport matplotlib.pyplot as plt%matplotlib inline
- Next, we take the MNIST data from the TensorFlow examples--the important thing to note here is that the labels are not one-hot encoded, simply because we are not using labels to train the network. Autoencoders learn via unsupervised learning:
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 declare a class AutoEncoder; the class has the init method to initialize weights, ...