Building an Auto-Encoder using Keras
This article will demonstrate the process of data compression and the reconstruction of the encoded data by using Machine Learning by first building an Auto-encoder using Keras and then reconstructing the encoded data and visualizing the reconstruction. We would be using the MNIST handwritten digits dataset which is preloaded into the Keras module about which you can read here.
The code is structured as follows: First all the utility functions are defined which are needed at different steps of the building of the Auto-encoder are defined and then each function is called accordingly.
Step 1: Importing the required libraries
Step 2: Defining a utility function to load the data
Note: While loading the data, notice that the space where the training labels are loaded are kept empty because the compression process does not involve the output labels
Step 3: Defining a utility function to build the Auto-encoder neural network
Step 4: Defining a utility function to build and train the Auto-encoder network
Step 5: Defining a utility function to visualize the reconstruction
Step 6: Calling the utility functions in the appropriate order
a) Loading the data
b) Building the network
c) Building and training the Auto-encoder
d) Visualizing the reconstruction