Feature engineering for image data
One of the most prominent feature extraction methods for image data is the use of convolutional neural networks (CNNs) and extracting embeddings from these networks. In recent years, a new type of this kind of neural network was introduced – autoencoders. Although we can use autoencoders for all kinds of data, they are particularly well-suited for images. So, let’s construct an autoencoder for the MNIST dataset and extract bottleneck values from it.
First, we need to download the MNIST dataset using the following code fragment:
# first, let's read the image data from the Keras library from tensorflow.keras.datasets import mnist # and load it with the pre-defined train/test splits (X_train, y_train), (X_test, y_test) = mnist.load_data() X_train = X_train/255.0 X_test = X_test/255.0
Now, we can construct the encoder part by using the following code. Please note that there is one extra layer in the encoder part. The goal of...