This article will demonstrate the process of compressing data and recovering encoded data using machine learning by first building an auto-encoder using Keras, and then recovering the encoded data and visualizing the recovery. We will be using the MNIST handwritten number set which is pre-loaded into the Keras module, about which you can read here .
The code is structured as follows: first, all the utility functions that are needed at different stages of building the autoencoder are defined, and then each function is called accordingly.
Step 1: Import the required libraries
|
Step 2: Define a utility function for loading data
|
Note. When loading data, note that the space into which the training labels are loaded remains empty because no output labels are used during the compression process.
Step 3: Defining a utility function for building the Auto-encoder neural network
|
Step 4: Define a utility function to build and train an auto-encoder network
|
Step 5: Defining a utility function for rendering a reconstruction
|
Step 6: Call the utility functions in the appropriate order
a) Data loading
|
b) networking
|
c) Create and train an auto-encoder
|
|