Feature standardization of image data
In this recipe, we will look at how Keras can be used for feature standardization of image data.
Getting ready
Make sure the Keras installation and Jupyter Notebook installation have been completed.
How to do it...
We will be using the mnist dataset. First, let's plot the mnist images without standardization:
from keras.datasets import mnist
from matplotlib import pyplot
(X_train, y_train), (X_test, y_test) = mnist.load_data()
# create a grid of 3x3 images
for i in range(0, 9):
ax = pyplot.subplot(330 + 1 + i)
pyplot.tight_layout()
ax.tick_params(axis='x', colors='white')
ax.tick_params(axis='y', colors='white')
pyplot.imshow(X_train[i], cmap=pyplot.get_cmap('gray'))
# show the plot
pyplot.show()The output plot will be similar to the following screenshot:

For feature standardization, we are planning to use ImageDataGenerator.
Initializing ImageDataGenerator
Use keras.preprocessing.image.ImageDataGenerator(featurewise_center=False, samplewise_center...