Implementing a convolutional autoencoder
In the previous chapter, we how to implement an autoencoder for the Street View House Numbers
dataset. We got some decent results, but the output could definitely be improved. In the following recipe, we will show how a convolutional autoencoder produces better outputs.
How to do it...
- Let's start with importing the libraries as follows:
import numpy as np import scipy.io from matplotlib import pyplot as plt from keras.utils import np_utils from keras.models import Sequential, Input, Model from keras.layers.core import Dense, Dropout, Activation, Reshape, Flatten, Lambda from keras.layers import Conv2D, MaxPooling2D, UpSampling2D from keras.callbacks import EarlyStopping
- Next, we load the dataset and extract the data we will use in this recipe:
mat = scipy.io.loadmat('Data/train_32x32.mat') mat = mat['X'] b, h, d, n = mat.shape
- Before feeding the data to our network, we pre-process the data:
#Convert all RGB-Images to greyscale img_gray = np.zeros(shape...