Compressing the MNIST dataset
In this part, we'll build a simple autoencoder that can be used to compress the MNIST dataset. So we will feed the images of this dataset to the encoder part, which will try to learn a lower compressed representation for them; then we will try to construct the input images again in the decoder part.
The MNIST dataset
We will start the implementation by getting the MNIST dataset, using the helper functions of TensorFlow.
Let's import the necessary packages for this implementation:
%matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data mnist_dataset = input_data.read_data_sets('MNIST_data', validation_size=0) Output: Extracting MNIST_data/train-images-idx3-ubyte.gz Extracting MNIST_data/train-labels-idx1-ubyte.gz Extracting MNIST_data/t10k-images-idx3-ubyte.gz Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
Let's start off by plotting some examples from the MNIST dataset...