Original Code:
# Load And Plot Sample CIFAR-10 Images
# Plot ad hoc CIFAR-10 instances
from keras.datasets import cifar10
from matplotlib import pyplot
from scipy.misc import toimage
# load data
(X_train, y_train),(X_test, y_test) = cifar10.load_data()
# create a grid of 3 x 3 images
for i in range(0, 9):
pyplot.subplot(330 + 1 + i)
pyplot.imshow(toimage(X_train[i]))
# show the plot
pyplot.show()
Modified Code:
# Load And Plot Sample CIFAR-10 Images
# Plot ad hoc CIFAR-10 instances
from keras.datasets import cifar10
from matplotlib import pyplot
from PIL import Image
# load data
(X_train, y_train),(X_test, y_test) = cifar10.load_data()
# create a grid of 3 x 3 images
for i in range(0, 9):
pyplot.subplot(330 + 1 + i)
pyplot.imshow(Image.fromarray(X_train[i]))
# show the plot
pyplot.show()